@@ -72,6 +72,7 @@ gamescope::ConVar<bool> cv_drm_debug_disable_color_range( "drm_debug_disable_col
72
72
gamescope::ConVar<bool > cv_drm_debug_disable_explicit_sync ( " drm_debug_disable_explicit_sync" , false , " Force disable explicit sync on the DRM backend." );
73
73
gamescope::ConVar<bool > cv_drm_debug_disable_in_fence_fd ( " drm_debug_disable_in_fence_fd" , false , " Force disable IN_FENCE_FD being set to avoid over-synchronization on the DRM backend." );
74
74
75
+ gamescope::ConVar<bool > cv_drm_allow_dynamic_modes_for_external_display ( " drm_allow_dynamic_modes_for_external_display" , false , " Allow dynamic mode/refresh rate switching for external displays." );
75
76
76
77
int HackyDRMPresent ( const FrameInfo_t *pFrameInfo, bool bAsync );
77
78
@@ -2184,6 +2185,8 @@ namespace gamescope
2184
2185
bool bHasKnownColorimetry = false ;
2185
2186
bool bHasKnownHDRInfo = false ;
2186
2187
2188
+ m_Mutable.ValidDynamicRefreshRates .clear ();
2189
+ m_Mutable.fnDynamicModeGenerator = nullptr ;
2187
2190
{
2188
2191
CScriptScopedLock script;
2189
2192
@@ -2197,8 +2200,6 @@ namespace gamescope
2197
2200
(int )oKnownDisplay->first .size (), oKnownDisplay->first .data (),
2198
2201
(int )psvPrettyName.size (), psvPrettyName.data () );
2199
2202
2200
- m_Mutable.fnDynamicModeGenerator = nullptr ;
2201
- m_Mutable.ValidDynamicRefreshRates .clear ();
2202
2203
2203
2204
sol::optional<sol::table> otDynamicRefreshRates = tTable[" dynamic_refresh_rates" ];
2204
2205
sol::optional<sol::function> ofnDynamicModegen = tTable[" dynamic_modegen" ];
@@ -2285,6 +2286,34 @@ namespace gamescope
2285
2286
bHasKnownHDRInfo = true ;
2286
2287
}
2287
2288
}
2289
+ else
2290
+ {
2291
+ // Unknown display, see if there are any other refresh rates in the EDID we can get.
2292
+ if ( GetScreenType () == GAMESCOPE_SCREEN_TYPE_INTERNAL || cv_drm_allow_dynamic_modes_for_external_display )
2293
+ {
2294
+ const drmModeModeInfo *pPreferredMode = find_mode ( m_pConnector.get (), 0 , 0 , 0 );
2295
+
2296
+ if ( pPreferredMode )
2297
+ {
2298
+ // See if the EDID has any modes for us.
2299
+ for (int i = 0 ; i < m_pConnector->count_modes ; i++)
2300
+ {
2301
+ const drmModeModeInfo *pMode = &m_pConnector->modes [i];
2302
+
2303
+ if ( pMode->hdisplay != pPreferredMode->hdisplay || pMode->vdisplay != pPreferredMode->vdisplay )
2304
+ continue ;
2305
+
2306
+
2307
+ if ( !Algorithm::Contains ( m_Mutable.ValidDynamicRefreshRates , pMode->vrefresh ) )
2308
+ {
2309
+ m_Mutable.ValidDynamicRefreshRates .push_back ( pMode->vrefresh );
2310
+ }
2311
+ }
2312
+
2313
+ std::sort ( m_Mutable.ValidDynamicRefreshRates .begin (), m_Mutable.ValidDynamicRefreshRates .end () );
2314
+ }
2315
+ }
2316
+ }
2288
2317
}
2289
2318
2290
2319
if ( !bHasKnownColorimetry )
0 commit comments