Report the panel's active refresh rate to the gndrm daemon

Closed
UT
11d ago
+38-1

What this fixes

Under gamescope the daemon measures the panel's latch grid (vsync.rs) against the refresh rate the app reports through GameNativeDrm.nativeSetPanelRefreshHz. The app reported detectMaxRefreshRateHz, the fastest mode the panel supports, so on a panel a user holds at 60 Hz the daemon tracked a 120 Hz lattice and told the shims the latch period was 8.33 ms. The gamescope frame-rate limit is about to place its releases on that grid (GameNative/gamescope#21 A52, GameNative/gamenative-drm#33): with the wrong period it snaps to points that are not latch points, and commits land on the edge of the real window. Measured on the Odin 3 (panel at 60 Hz, maximum 120): the ICD logged panel grid period=8333us, and the capped session lost more frames at the latch than before.

The change

  • detectActiveRefreshRateHz: the display's current mode (Display.refreshRate), falling back to the maximum only when it cannot be read.
  • The gamescope branch of session setup reports the active rate ahead of nativeStart, and registers a DisplayManager.DisplayListener that reports it again on onDisplayChanged, so a mode switch mid-session (a user toggling 60/120, a game-mode profile) reaches the daemon. The listener is unregistered at session exit, just before nativeStop.
  • detectMaxRefreshRateHz stays for the limiter's ceiling and the emulated mode's rate elsewhere.

Verification

  • :app:compileModernDebugKotlin passes.
  • Device verification of the capped gamescope session with the three PRs together is pending an installed build.

Stacked on #2283 (base branch fix/gamescope-resolution-scanout).