From dd5f0b1f5b4fac4f84014d62c0030a848374b0ae Mon Sep 17 00:00:00 2001 From: Matthew Schwartz Date: Thu, 7 Nov 2024 18:02:03 -0800 Subject: [PATCH] scripts: add support for ascii in EDID Two panel models exist for the ROG Ally X, one has panel information stored as "Alphanumeric Data String: " according to edid-decode. Add support for retrieving said data string to use for panel matching. Co-developed-by: sharkautarch <128002472+sharkautarch@users.noreply.github.com> --- .../displays/asus.rogally.lcd.lua | 24 +++++++++++-- src/Backends/DRMBackend.cpp | 34 ++++++++++++------- src/Script/Script.cpp | 3 +- src/Script/Script.h | 2 +- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/scripts/00-gamescope/displays/asus.rogally.lcd.lua b/scripts/00-gamescope/displays/asus.rogally.lcd.lua index 11ba7cc30..64ccb4cb8 100644 --- a/scripts/00-gamescope/displays/asus.rogally.lcd.lua +++ b/scripts/00-gamescope/displays/asus.rogally.lcd.lua @@ -65,12 +65,30 @@ gamescope.config.known_displays.rogally_lcd = { -- There is only a single panel model in use across both -- ROG Ally + ROG Ally X. matches = function(display) - if display.vendor == "TMX" and display.model == "TL070FVXS01-0" and display.product == 0x0002 then - debug("[rogally_lcd] Matched vendor: "..display.vendor.." model: "..display.model.." product:"..display.product) - return 5000 + local lcd_types = { + { vendor = "TMX", model = "TL070FVXS01-0", product = 0x0002 }, + { vendor = "BOE", product = 0x3123, data_ascii = "TS070FHM-LU0" }, + } + + for index, value in ipairs(lcd_types) do + if display.vendor == value.vendor and display.product == value.product then + if value.model and display.model == value.model then + debug("[rogally_lcd] Matched vendor: " .. display.vendor .. + " model: " .. display.model .. + " product: " .. string.format("0x%04X", display.product)) + return 5000 + elseif value.data_ascii and display.data_ascii == value.data_ascii then + debug("[rogally_lcd] Matched vendor: " .. display.vendor .. + " alphanumeric data string: " .. display.data_ascii .. + " product: " .. string.format("0x%04X", display.product)) + return 5000 + end + end end + return -1 end + } debug("Registered ASUS ROG Ally/Ally X LCD as a known display") --debug(inspect(gamescope.config.known_displays.rogally_lcd)) diff --git a/src/Backends/DRMBackend.cpp b/src/Backends/DRMBackend.cpp index 0b121e841..2fbb6c970 100644 --- a/src/Backends/DRMBackend.cpp +++ b/src/Backends/DRMBackend.cpp @@ -392,6 +392,7 @@ namespace gamescope char szName[32]{}; char szMakePNP[4]{}; char szModel[16]{}; + char szDataAscii[16]{}; const char *pszMake = ""; // Not owned, no free. This is a pointer to pnp db or szMakePNP. std::vector ValidDynamicRefreshRates{}; DRMModeGenerator fnDynamicModeGenerator; @@ -2125,19 +2126,26 @@ namespace gamescope m_Mutable.pszMake = pnpIter->second.c_str(); const di_edid_display_descriptor *const *pDescriptors = di_edid_get_display_descriptors( pEdid ); - for ( size_t i = 0; pDescriptors[i] != nullptr; i++ ) - { - const di_edid_display_descriptor *pDesc = pDescriptors[i]; - if ( di_edid_display_descriptor_get_tag( pDesc ) == DI_EDID_DISPLAY_DESCRIPTOR_PRODUCT_NAME ) - { - // Max length of di_edid_display_descriptor_get_string is 14 - // m_szModel is 16 bytes. - const char *pszModel = di_edid_display_descriptor_get_string( pDesc ); - strncpy( m_Mutable.szModel, pszModel, sizeof( m_Mutable.szModel ) ); - } - } + for ( size_t i = 0; pDescriptors[i] != nullptr; i++ ) + { + const di_edid_display_descriptor *pDesc = pDescriptors[i]; + if ( di_edid_display_descriptor_get_tag( pDesc ) == DI_EDID_DISPLAY_DESCRIPTOR_PRODUCT_NAME ) + { + // Max length of di_edid_display_descriptor_get_string is 14 + // m_szModel is 16 bytes. + const char *pszModel = di_edid_display_descriptor_get_string( pDesc ); + strncpy( m_Mutable.szModel, pszModel, sizeof( m_Mutable.szModel ) ); + } else if ( di_edid_display_descriptor_get_tag( pDesc ) == DI_EDID_DISPLAY_DESCRIPTOR_DATA_STRING ) + { + // Max length of di_edid_display_descriptor_get_string is 14 + // szDataAscii is 16 bytes. + const char *pszDataAscii = di_edid_display_descriptor_get_string( pDesc ); + strncpy( m_Mutable.szDataAscii, pszDataAscii, sizeof( m_Mutable.szDataAscii ) ); + m_Mutable.szDataAscii[ sizeof( m_Mutable.szDataAscii ) - 1 ] = '\0'; + } + } - drm_log.infof("Connector %s -> %s - %s", m_Mutable.szName, m_Mutable.szMakePNP, m_Mutable.szModel ); + drm_log.infof("Connector %s -> %s - %s - %s", m_Mutable.szName, m_Mutable.szMakePNP, m_Mutable.szModel, m_Mutable.szDataAscii ); bool bHasKnownColorimetry = false; bool bHasKnownHDRInfo = false; @@ -2145,7 +2153,7 @@ namespace gamescope { CScriptScopedLock script; - auto oKnownDisplay = script.Manager().Gamescope().Config.LookupDisplay( script, m_Mutable.szMakePNP, pProduct->product, m_Mutable.szModel ); + auto oKnownDisplay = script.Manager().Gamescope().Config.LookupDisplay( script, m_Mutable.szMakePNP, pProduct->product, m_Mutable.szModel, m_Mutable.szDataAscii ); if ( oKnownDisplay ) { sol::table tTable = oKnownDisplay->second; diff --git a/src/Script/Script.cpp b/src/Script/Script.cpp index a104ee993..3fb81b203 100644 --- a/src/Script/Script.cpp +++ b/src/Script/Script.cpp @@ -247,7 +247,7 @@ namespace gamescope // GamescopeScript_t // - std::optional> GamescopeScript_t::Config_t::LookupDisplay( CScriptScopedLock &script, std::string_view psvVendor, uint16_t uProduct, std::string_view psvModel ) + std::optional> GamescopeScript_t::Config_t::LookupDisplay( CScriptScopedLock &script, std::string_view psvVendor, uint16_t uProduct, std::string_view psvModel, std::string_view psvDataAscii ) { int nMaxPrority = -1; std::optional> oOutDisplay; @@ -256,6 +256,7 @@ namespace gamescope tDisplay["vendor"] = psvVendor; tDisplay["product"] = uProduct; tDisplay["model"] = psvModel; + tDisplay["data_ascii"] = psvDataAscii; for ( auto iter : KnownDisplays ) { diff --git a/src/Script/Script.h b/src/Script/Script.h index 6eebb66a9..74875679a 100644 --- a/src/Script/Script.h +++ b/src/Script/Script.h @@ -30,7 +30,7 @@ namespace gamescope sol::table KnownDisplays; - std::optional> LookupDisplay( CScriptScopedLock &script, std::string_view psvVendor, uint16_t uProduct, std::string_view psvModel ); + std::optional> LookupDisplay( CScriptScopedLock &script, std::string_view psvVendor, uint16_t uProduct, std::string_view psvModel, std::string_view psvDataAscii ); } Config; };