Skip to content

Commit

Permalink
edid: Avoid using g_bRotated
Browse files Browse the repository at this point in the history
  • Loading branch information
misyltoad committed Feb 6, 2024
1 parent 81663f4 commit e1a6456
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/drm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -3429,7 +3429,7 @@ namespace gamescope
if ( !GetCurrentConnector() )
return;

WritePatchedEdid( GetCurrentConnector()->GetRawEDID(), GetCurrentConnector()->GetHDRInfo() );
WritePatchedEdid( GetCurrentConnector()->GetRawEDID(), GetCurrentConnector()->GetHDRInfo(), g_bRotated );
}

protected:
Expand Down
10 changes: 4 additions & 6 deletions src/edid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ extern "C"
#include "libdisplay-info/cta.h"
}

extern bool g_bRotated;

static LogScope edid_log("josh edid");

namespace gamescope
Expand Down Expand Up @@ -89,15 +87,15 @@ namespace gamescope
return ceilf((logf(nits / 50.0f) / logf(2.0f)) * 32.0f);
}

std::optional<std::vector<uint8_t>> PatchEdid( std::span<const uint8_t> pEdid, const BackendConnectorHDRInfo &hdrInfo )
std::optional<std::vector<uint8_t>> PatchEdid( std::span<const uint8_t> pEdid, const BackendConnectorHDRInfo &hdrInfo, bool bRotate )
{
// A zero length indicates that the edid parsing failed.
if ( pEdid.empty() )
return std::nullopt;

std::vector<uint8_t> 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]);
Expand Down Expand Up @@ -263,15 +261,15 @@ namespace gamescope
return pszPatchedEdidPath;
}

void WritePatchedEdid( std::span<const uint8_t> pEdid, const BackendConnectorHDRInfo &hdrInfo )
void WritePatchedEdid( std::span<const uint8_t> pEdid, const BackendConnectorHDRInfo &hdrInfo, bool bRotate )
{
const char *pszPatchedEdidPath = GetPatchedEdidPath();
if ( !pszPatchedEdidPath )
return;

std::span<const uint8_t> pEdidToWrite = pEdid;

auto oPatchedEdid = PatchEdid( pEdid, hdrInfo );
auto oPatchedEdid = PatchEdid( pEdid, hdrInfo, bRotate );
if ( oPatchedEdid )
pEdidToWrite = std::span<const uint8_t>{ oPatchedEdid->begin(), oPatchedEdid->end() };

Expand Down
4 changes: 2 additions & 2 deletions src/edid.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace gamescope
struct BackendConnectorHDRInfo;

const char *GetPatchedEdidPath();
void WritePatchedEdid( std::span<const uint8_t> pEdid, const BackendConnectorHDRInfo &hdrInfo );
void WritePatchedEdid( std::span<const uint8_t> pEdid, const BackendConnectorHDRInfo &hdrInfo, bool bRotate );

std::optional<std::vector<uint8_t>> PatchEdid( std::span<const uint8_t> pEdid, const BackendConnectorHDRInfo &hdrInfo );
std::optional<std::vector<uint8_t>> PatchEdid( std::span<const uint8_t> pEdid, const BackendConnectorHDRInfo &hdrInfo, bool bRotate );
}

0 comments on commit e1a6456

Please sign in to comment.