From 5ffc5247e873d72020886f01cb487fb3a9cbc252 Mon Sep 17 00:00:00 2001 From: 17314642 <48242771@protonmail.ch> Date: Sun, 29 Dec 2024 10:41:10 +0300 Subject: [PATCH] bring back old pci_dev config format previously "0000:03:00.0" was equal to "0:03:00.0" because it got converted. so bring that back to avoid breaking existing configs. --- src/overlay_params.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/overlay_params.cpp b/src/overlay_params.cpp index 63291228ef..9fbe4a4fc4 100644 --- a/src/overlay_params.cpp +++ b/src/overlay_params.cpp @@ -767,6 +767,29 @@ static void set_param_defaults(struct overlay_params *params){ params->text_outline_thickness = 1.5; } +static std::string verify_pci_dev(std::string pci_dev) { + uint32_t domain, bus, slot, func; + + if ( + sscanf( + pci_dev.c_str(), "%04x:%02x:%02x.%x", + &domain, &bus, &slot, &func + ) != 4) { + SPDLOG_ERROR("Failed to parse PCI device ID: '{}'", pci_dev); + return pci_dev; + } + + std::stringstream ss; + ss << std::hex + << std::setw(4) << std::setfill('0') << domain << ":" + << std::setw(2) << bus << ":" + << std::setw(2) << slot << "." + << std::setw(1) << func; + + SPDLOG_DEBUG("pci_dev = {}", ss.str()); + return ss.str(); +} + void parse_overlay_config(struct overlay_params *params, const char *env, bool use_existing_preset) @@ -1000,6 +1023,9 @@ parse_overlay_config(struct overlay_params *params, ); } + if (!params->pci_dev.empty()) + params->pci_dev = verify_pci_dev(params->pci_dev); + { std::lock_guard lock(config_mtx); config_ready = true;