Repository navigation
Generate screen modes at the exact requested size and refresh rate - #31
Open
masnwilliams wants to merge 1 commit into
Open
masnwilliams wants to merge 1 commit into
masnwilliams wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When no existing mode matches a requested screen size,
ChangeScreenSizecreates one with libxcvt and then sets it withXRRSetScreenConfigAndRateat the requested integer rate. For some sizes the generated mode can't be set at that rate, so neko returns 422unsupported screen rate 60. Mostly these are short or small screens: 1008x384, 976x384, 1024x384, 1200x384, 1008x368, 788x300, 630x240 and 379x480 all fail at 60 Hz, and 1008x384 also fails at 25 Hz.There are two causes, both in how libxcvt output is used:
libxcvt.c). On small modes that cuts the real rate by up to about 1%. For example, 1008x384@60 comes out at 29.750 MHz, htotal 1248 and vtotal 401, which is 59.45 Hz. X lists a mode's rate rounded to the nearest integer (RRVerticalRefresh), so this mode is listed at 59 and a request for 60 fails withBadValue.Change
XCreateScreenModeInfo:htotal * vtotal * vrefresh, so X lists the mode at exactly the requested rate.%dx%d_%d), the same as the build without libxcvt already did.Modes defined in
xorg.confare untouched:ChangeScreenSizestill tries an existing mode first.Testing
TestNewScreenModeInfochecks the generated size, the rate as X lists it, and the ordering of the timings for 18 sizes × 5 rates. On the old code it fails with 80 errors, for example1008x384@60: X lists the mode at 59 Hz. On this change it passes.PATCH /displayand/configure(with--kiosk) through kernel-images-api. Every size above went from 422 to 200. xrandr reports the exact size at60.00Hz, and Chromium'sscreen.width/heightmatch.788x300 screen 788x300. The live view<video>played at 1003x500 and 630x240. Recording at an odd size (379x481) produced a valid mp4, because the recorder already pads odd dimensions.Notes
Note
Medium Risk
Changes low-level X RandR timing and dot-clock math used whenever dynamic display sizes are created; incorrect values could break display configuration, though behavior is covered by new unit tests.
Overview
Fixes
422 unsupported screen rateand wrong dimensions whenChangeScreenSizecreates a custom RandR mode via libxcvt for sizes that are not already in X.XCreateScreenModeInfonow always uses the requested width and height for the mode geometry and name, while libxcvt timings are computed on a width rounded up to a multiple of 8 so odd widths (e.g. 1003×500) are no longer shrunk and cases like 1360×768 are not widened to 1366. The pixel clock is set tohtotal × vtotal × vrefreshinstead of libxcvt’s 250 kHz–quantized clock, so X lists the mode at the requested integer Hz andXRRSetScreenConfigAndRateaccepts the rate (e.g. 1008×384@60 no longer rounds to 59 Hz).Go adds
newScreenModeInfo/screenModeInfoso tests can inspect generated modes without registering them on the X server.TestNewScreenModeInfochecks exact size, X-style refresh rounding, and valid sync/total ordering across many previously failing sizes and rates.Reviewed by Cursor Bugbot for commit a37cfdb. Bugbot is set up for automated code reviews on this repo. Configure here.