alex-courtis / way-displays

way-displays: Auto Manage Your Wayland Displays
MIT License
253 stars 13 forks source link

Feature: Maximum Preferred Refresh #10

Closed skyne98 closed 2 years ago

skyne98 commented 2 years ago

Hey there!

Quick question, is there an option for the tool to try to force the maximum refresh rate using the resolution from the "preferred" configuration (for stability)?

alex-courtis commented 2 years ago

It is possible: that was how the predecessor xlayoutdisplay functioned. I think that might have been a primary motivation to build it.

I don't have a monitor whose preferred mode's refresh is not the maximum, however I am guessing that you do. Would you like to experiment with this and see what we can do?

Options:

  1. You hack it into way-displays and raise a PR if successful
  2. I produce a branch with this functionality for you to test drive
  3. You attempt the refresh override via sway e.g. output DP-3 mode 800x600@180Hz

Option 3 does not follow the same codepath as way-displays, so we will still need to test with 1 or 2 afterwards.

skyne98 commented 2 years ago

Hacking into stuff would be a little difficult for me, as my experience with C codebases is close to 0, but I can certainly help out with the option number 2! I have a 1920x1080@144Hz where I can test things.

Actually, I have two displays (another one is 2560×1440@60Hz), so it will also be possible for me to make sure that the utility keeps both of them with sane configurations.

alex-courtis commented 2 years ago

Let's live dangerously and skip 3. I'll build 2 for you to test.

Before I do that, please send me some information about your monitor:

I'm looking for something like:

I [09:11:06.820] DP-3 Arrived:
I [09:11:06.820]   info:
I [09:11:06.820]     name:     'DP-3'
I [09:11:06.820]     desc:     'Unknown ASUS XG32V 0x0000CF52 (DP-3 via HDMI)'
I [09:11:06.820]     width:    700mm
I [09:11:06.820]     height:   390mm
I [09:11:06.820]     dpi:      93.34 @ 2560x1440
D [09:11:06.820]     mode:     720x400@70Hz
D [09:11:06.820]     mode:     640x480@60Hz
...
D [09:11:06.820]     mode:     2560x1440@100Hz
D [09:11:06.820]     mode:     2560x1440@120Hz
D [09:11:06.820]     mode:     2560x1440@144Hz (preferred)

I think we'll see something like 1920x1080@60Hz (preferred) on the 144Hz monitor.

skyne98 commented 2 years ago

Ok! Will do as soon as I have a little of free time (probably on weekends).

alex-courtis commented 2 years ago

I have built a version that always picks the highest refresh rate for the preferred resolution. An option can come later.

I would be grateful for your testing and feedback.

Build and install:

git clone git@github.com:alex-courtis/way-displays.git
cd way-displays
git checkout 10-max-optimal-refresh
make
sudo make install

Please add LOG_THRESHOLD: DEBUG to your cfg.yaml before starting.

If things work as intended, we will get something like overriding preferred mode refresh to 144...mHz in the log, and the mode will be the highest refresh.

I would be grateful if you could reply with your log, even if things go well. My testing has been synthetic and I'm flying pretty blind.

Once you're done, you can remove the test version from /usr/local:

sudo make uninstall
skyne98 commented 2 years ago

Hey there! Sorry for the delay! Here is the log I got:

I [16:32:36.544] way-displays version 1.1.1-SNAPSHOT
I [16:32:36.544]
I [16:32:36.544] Found configuration file: /home/fox/.config/way-displays/cfg.yaml
I [16:32:36.544]   Arrange in a ROW aligned at the TOP
I [16:32:36.544]   Auto scale: ON
I [16:32:36.545]
I [16:32:36.545] HDMI-A-1 Arrived:
I [16:32:36.545]   info:
I [16:32:36.545]     name:     'HDMI-A-1'
I [16:32:36.545]     desc:     'Lenovo Group Limited L24q-10 U4P05K4X (HDMI-A-1)'
I [16:32:36.545]     width:    530mm
I [16:32:36.545]     height:   300mm
I [16:32:36.545]     dpi:      122.30 @ 2560x1440
D [16:32:36.545]     mode:     2560x1440@59951mHz (preferred)
D [16:32:36.545]     mode:     1920x1200@59950mHz
D [16:32:36.545]     mode:     1920x1080@60000mHz
D [16:32:36.545]     mode:     1920x1080@60000mHz
D [16:32:36.545]     mode:     1920x1080@59940mHz
D [16:32:36.545]     mode:     1920x1080@50000mHz
D [16:32:36.545]     mode:     1920x1080@50000mHz
D [16:32:36.545]     mode:     1600x1200@59951mHz
D [16:32:36.545]     mode:     1680x1050@59883mHz
D [16:32:36.545]     mode:     1600x900@60000mHz
D [16:32:36.545]     mode:     1280x1024@75025mHz
D [16:32:36.545]     mode:     1280x1024@60020mHz
D [16:32:36.545]     mode:     1440x900@59901mHz
D [16:32:36.545]     mode:     1280x800@59951mHz
D [16:32:36.545]     mode:     1152x864@75000mHz
D [16:32:36.545]     mode:     1280x720@60000mHz
D [16:32:36.545]     mode:     1280x720@60000mHz
D [16:32:36.545]     mode:     1280x720@59940mHz
D [16:32:36.545]     mode:     1280x720@50000mHz
D [16:32:36.545]     mode:     1024x768@75029mHz
D [16:32:36.545]     mode:     1024x768@70069mHz
D [16:32:36.545]     mode:     1024x768@60004mHz
D [16:32:36.545]     mode:     800x600@75000mHz
D [16:32:36.545]     mode:     800x600@72188mHz
D [16:32:36.545]     mode:     800x600@60317mHz
D [16:32:36.545]     mode:     800x600@56250mHz
D [16:32:36.545]     mode:     720x576@50000mHz
D [16:32:36.545]     mode:     720x576@50000mHz
D [16:32:36.545]     mode:     720x480@60000mHz
D [16:32:36.545]     mode:     720x480@60000mHz
D [16:32:36.545]     mode:     720x480@59940mHz
D [16:32:36.545]     mode:     720x480@59940mHz
D [16:32:36.545]     mode:     720x480@59940mHz
D [16:32:36.545]     mode:     640x480@75000mHz
D [16:32:36.545]     mode:     640x480@72809mHz
D [16:32:36.545]     mode:     640x480@66667mHz
D [16:32:36.545]     mode:     640x480@60000mHz
D [16:32:36.545]     mode:     640x480@59940mHz
D [16:32:36.545]     mode:     640x480@59940mHz
D [16:32:36.545]     mode:     720x400@70082mHz
I [16:32:36.545]   current:
I [16:32:36.545]     scale:    1.000
I [16:32:36.545]     position: 1920,0
I [16:32:36.545]     mode:     2560x1440@59951mHz (preferred)
I [16:32:36.545]
I [16:32:36.545] DP-3 Arrived:
I [16:32:36.545]   info:
I [16:32:36.545]     name:     'DP-3'
I [16:32:36.545]     desc:     'Unknown 24G2W1G4 0x000020B8 (DP-3)'
I [16:32:36.545]     width:    530mm
I [16:32:36.545]     height:   300mm
I [16:32:36.545]     dpi:      91.73 @ 1920x1080
D [16:32:36.545]     mode:     1920x1080@60000mHz (preferred)
D [16:32:36.545]     mode:     1920x1080@144001mHz
D [16:32:36.545]     mode:     1920x1080@120000mHz
D [16:32:36.545]     mode:     1920x1080@119880mHz
D [16:32:36.545]     mode:     1920x1080@119982mHz
D [16:32:36.545]     mode:     1920x1080@99930mHz
D [16:32:36.545]     mode:     1920x1080@60000mHz
D [16:32:36.545]     mode:     1920x1080@59940mHz
D [16:32:36.545]     mode:     1920x1080@50000mHz
D [16:32:36.545]     mode:     1680x1050@59883mHz
D [16:32:36.545]     mode:     1280x1024@75025mHz
D [16:32:36.545]     mode:     1280x1024@60020mHz
D [16:32:36.545]     mode:     1440x900@59901mHz
D [16:32:36.545]     mode:     1280x800@60000mHz
D [16:32:36.545]     mode:     1280x720@60000mHz
D [16:32:36.545]     mode:     1280x720@60000mHz
D [16:32:36.545]     mode:     1280x720@59940mHz
D [16:32:36.545]     mode:     1280x720@50000mHz
D [16:32:36.545]     mode:     1024x768@119926mHz
D [16:32:36.545]     mode:     1024x768@99991mHz
D [16:32:36.545]     mode:     1024x768@75029mHz
D [16:32:36.545]     mode:     1024x768@70069mHz
D [16:32:36.545]     mode:     1024x768@60004mHz
D [16:32:36.545]     mode:     832x624@74551mHz
D [16:32:36.545]     mode:     800x600@119933mHz
D [16:32:36.545]     mode:     800x600@99862mHz
D [16:32:36.545]     mode:     800x600@75000mHz
D [16:32:36.545]     mode:     800x600@72188mHz
D [16:32:36.545]     mode:     800x600@60317mHz
D [16:32:36.545]     mode:     800x600@56250mHz
D [16:32:36.545]     mode:     720x576@50000mHz
D [16:32:36.545]     mode:     720x576@50000mHz
D [16:32:36.545]     mode:     720x480@60000mHz
D [16:32:36.545]     mode:     720x480@60000mHz
D [16:32:36.545]     mode:     720x480@59940mHz
D [16:32:36.545]     mode:     720x480@59940mHz
D [16:32:36.545]     mode:     640x480@119803mHz
D [16:32:36.545]     mode:     640x480@99825mHz
D [16:32:36.545]     mode:     640x480@75000mHz
D [16:32:36.545]     mode:     640x480@72809mHz
D [16:32:36.545]     mode:     640x480@66667mHz
D [16:32:36.545]     mode:     640x480@60000mHz
D [16:32:36.545]     mode:     640x480@59940mHz
D [16:32:36.545]     mode:     640x480@59940mHz
D [16:32:36.545]     mode:     720x400@70082mHz
I [16:32:36.545]   current:
I [16:32:36.545]     scale:    1.000
I [16:32:36.545]     position: 0,0
I [16:32:36.545]     mode:     1920x1080@60000mHz (preferred)
D [16:32:36.545]   overriding preferred mode refresh to 99930mHz
I [16:32:36.545]
I [16:32:36.545] HDMI-A-1 Changing:
I [16:32:36.545]   from:
I [16:32:36.545]     scale:    1.000
I [16:32:36.545]     position: 1920,0
I [16:32:36.545]     mode:     2560x1440@59951mHz (preferred)
I [16:32:36.545]   to:
I [16:32:36.545]     scale:    1.250
I [16:32:36.545]     position: 0,0
I [16:32:36.545]
I [16:32:36.545] DP-3 Changing:
I [16:32:36.545]   from:
I [16:32:36.545]     scale:    1.000
I [16:32:36.545]     position: 0,0
I [16:32:36.545]     mode:     1920x1080@60000mHz (preferred)
I [16:32:36.545]   to:
I [16:32:36.545]     position: 2048,0
I [16:32:36.545]     mode:     1920x1080@99930mHz
I [16:32:36.545]
I [16:32:36.545] Changes successful

It seems to have set my 144Hz display to ~100Hz instead, even though the 144Hz option is available in the list of modes. Also, not directly related to the topic, but what do you think about displaying the refresh rate as Hz instead of mHz? I think seeing such big numbers will definitely confuse people, at least at first glance. If numbers are not integers, we can just display it as a fraction, I guess? 99930mHz = 99.930 Hz.

alex-courtis commented 2 years ago

It seems to have set my 144Hz display to ~100Hz instead

We are getting closer... was the monitor happy with 100Hz?

Now that I have some real numbers I can test with them and get things working. New test incoming.

refresh rate as Hz instead of mHz

Definitely. I changed it to mHz just for our testing, so that we can tell the difference between 1920x1080@120000mHz and 1920x1080@119880mHz etc.

alex-courtis commented 2 years ago

Bug found and fixed. Please test again:

cd way-displays
git pull
make
sudo make install
skyne98 commented 2 years ago

Tested, seems to be fine now both on the 60Hz and 144Hz monitors!

raxetul commented 2 years ago

"10-max-optimal-refresh" branch also works with a 165 Hz monitor!

I'm also thinking about fixing into a specified resolution for some cases like some monitor controllers(a generic one for various display panels) report max resolution over native panel resolution. I will try to code some.