@@ -635,14 +635,32 @@ static bool X11_FillXRandRDisplayInfo(SDL_VideoDevice *_this, Display *dpy, int
635635 display -> internal = displaydata ;
636636
637637 if (info ) {
638- if (info -> max_luminance > 0.0 ) {
639- /* ITU-R BT.2408-7 (Sept 2023) has the reference PQ white level at 203 nits,
640- * while older Dolby documentation claims a reference level of 100 nits.
641- *
642- * Use 203 nits for now.
643- */
644- display -> HDR .HDR_headroom = (float )info -> max_luminance / 203.0f ;
645- display -> HDR .SDR_white_level = 1.0f ;
638+ /* ITU-R BT.2408-7 (Sept 2023) has the reference PQ white level at 203 nits,
639+ * while older Dolby documentation claims a reference level of 100 nits.
640+ *
641+ * Use 203 nits for now.
642+ */
643+ float SDR_white_level = 203.0f ;
644+
645+ bool steam_deck = SDL_GetHintBoolean ("SteamDeck" , false);
646+ if (steam_deck ) {
647+ // The SDR white level is dynamic, but typically is 400 nits
648+ // We'll need some other way to get this for external displays
649+ SDR_white_level = 400.0f ;
650+ } else {
651+ // Support for HDR on X11 seems spotty, let's disable this for now
652+ SDR_white_level = 0.0f ;
653+ }
654+
655+ // Allow a hint override for the SDR white level
656+ const char * hint = SDL_GetHint ("SDL_X11_SDR_WHITE_LEVEL" );
657+ if (hint && * hint ) {
658+ SDR_white_level = (float )SDL_atof (hint );
659+ }
660+
661+ if (info -> max_luminance > 0.0 && SDR_white_level > 0.0f ) {
662+ display -> HDR .HDR_headroom = (float )info -> max_luminance / SDR_white_level ;
663+ display -> HDR .SDR_white_level = SDR_white_level / 80.0f ;
646664 }
647665
648666 SDL_free (info );
0 commit comments