From e1a645681b9ced13a9ef93ca219ada96445114b9 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Mon, 5 Feb 2024 19:02:00 +0000 Subject: [PATCH] edid: Avoid using g_bRotated --- src/drm.cpp | 6 +++--- src/edid.cpp | 10 ++++------ src/edid.h | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/drm.cpp b/src/drm.cpp index 95a0853ee..5ff3cafcc 100644 --- a/src/drm.cpp +++ b/src/drm.cpp @@ -1022,7 +1022,7 @@ static bool setup_best_connector(struct drm_t *drm, bool force, bool initial) wlserver_unlock(); if (!initial) - WritePatchedEdid( best->GetRawEDID(), best->GetHDRInfo() ); + WritePatchedEdid( best->GetRawEDID(), best->GetHDRInfo(), g_bRotated ); update_connector_display_info_wl( drm ); @@ -3005,7 +3005,7 @@ namespace gamescope virtual bool PostInit() override { if ( g_DRM.pConnector ) - WritePatchedEdid( g_DRM.pConnector->GetRawEDID(), g_DRM.pConnector->GetHDRInfo() ); + WritePatchedEdid( g_DRM.pConnector->GetRawEDID(), g_DRM.pConnector->GetHDRInfo(), g_bRotated ); return true; } @@ -3429,7 +3429,7 @@ namespace gamescope if ( !GetCurrentConnector() ) return; - WritePatchedEdid( GetCurrentConnector()->GetRawEDID(), GetCurrentConnector()->GetHDRInfo() ); + WritePatchedEdid( GetCurrentConnector()->GetRawEDID(), GetCurrentConnector()->GetHDRInfo(), g_bRotated ); } protected: diff --git a/src/edid.cpp b/src/edid.cpp index 3f499fc98..eb855096a 100644 --- a/src/edid.cpp +++ b/src/edid.cpp @@ -15,8 +15,6 @@ extern "C" #include "libdisplay-info/cta.h" } -extern bool g_bRotated; - static LogScope edid_log("josh edid"); namespace gamescope @@ -89,7 +87,7 @@ namespace gamescope return ceilf((logf(nits / 50.0f) / logf(2.0f)) * 32.0f); } - std::optional> PatchEdid( std::span pEdid, const BackendConnectorHDRInfo &hdrInfo ) + std::optional> PatchEdid( std::span pEdid, const BackendConnectorHDRInfo &hdrInfo, bool bRotate ) { // A zero length indicates that the edid parsing failed. if ( pEdid.empty() ) @@ -97,7 +95,7 @@ namespace gamescope std::vector edid( pEdid.begin(), pEdid.end() ); - if ( g_bRotated ) + if ( bRotate ) { // Patch width, height. edid_log.infof("Patching dims %ux%u -> %ux%u", edid[0x15], edid[0x16], edid[0x16], edid[0x15]); @@ -263,7 +261,7 @@ namespace gamescope return pszPatchedEdidPath; } - void WritePatchedEdid( std::span pEdid, const BackendConnectorHDRInfo &hdrInfo ) + void WritePatchedEdid( std::span pEdid, const BackendConnectorHDRInfo &hdrInfo, bool bRotate ) { const char *pszPatchedEdidPath = GetPatchedEdidPath(); if ( !pszPatchedEdidPath ) @@ -271,7 +269,7 @@ namespace gamescope std::span pEdidToWrite = pEdid; - auto oPatchedEdid = PatchEdid( pEdid, hdrInfo ); + auto oPatchedEdid = PatchEdid( pEdid, hdrInfo, bRotate ); if ( oPatchedEdid ) pEdidToWrite = std::span{ oPatchedEdid->begin(), oPatchedEdid->end() }; diff --git a/src/edid.h b/src/edid.h index e6ab74688..2f821548d 100644 --- a/src/edid.h +++ b/src/edid.h @@ -10,7 +10,7 @@ namespace gamescope struct BackendConnectorHDRInfo; const char *GetPatchedEdidPath(); - void WritePatchedEdid( std::span pEdid, const BackendConnectorHDRInfo &hdrInfo ); + void WritePatchedEdid( std::span pEdid, const BackendConnectorHDRInfo &hdrInfo, bool bRotate ); - std::optional> PatchEdid( std::span pEdid, const BackendConnectorHDRInfo &hdrInfo ); + std::optional> PatchEdid( std::span pEdid, const BackendConnectorHDRInfo &hdrInfo, bool bRotate ); } \ No newline at end of file