Skip to content

Commit

Permalink
Merge branch 'panel-unknown-descriptor'
Browse files Browse the repository at this point in the history
  • Loading branch information
matte-schwartz committed Dec 3, 2024
2 parents 5c5eb0d + dd5f0b1 commit aade89d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 18 deletions.
24 changes: 21 additions & 3 deletions scripts/00-gamescope/displays/asus.rogally.lcd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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))
34 changes: 21 additions & 13 deletions src/Backends/DRMBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t> ValidDynamicRefreshRates{};
DRMModeGenerator fnDynamicModeGenerator;
Expand Down Expand Up @@ -2125,27 +2126,34 @@ 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;

{
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;
Expand Down
3 changes: 2 additions & 1 deletion src/Script/Script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ namespace gamescope
// GamescopeScript_t
//

std::optional<std::pair<std::string_view, sol::table>> GamescopeScript_t::Config_t::LookupDisplay( CScriptScopedLock &script, std::string_view psvVendor, uint16_t uProduct, std::string_view psvModel )
std::optional<std::pair<std::string_view, sol::table>> 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<std::pair<std::string_view, sol::table>> oOutDisplay;
Expand All @@ -256,6 +256,7 @@ namespace gamescope
tDisplay["vendor"] = psvVendor;
tDisplay["product"] = uProduct;
tDisplay["model"] = psvModel;
tDisplay["data_ascii"] = psvDataAscii;

for ( auto iter : KnownDisplays )
{
Expand Down
2 changes: 1 addition & 1 deletion src/Script/Script.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace gamescope

sol::table KnownDisplays;

std::optional<std::pair<std::string_view, sol::table>> LookupDisplay( CScriptScopedLock &script, std::string_view psvVendor, uint16_t uProduct, std::string_view psvModel );
std::optional<std::pair<std::string_view, sol::table>> LookupDisplay( CScriptScopedLock &script, std::string_view psvVendor, uint16_t uProduct, std::string_view psvModel, std::string_view psvDataAscii );
} Config;
};

Expand Down

0 comments on commit aade89d

Please sign in to comment.