From 4378e579752714d1b2259ebb88c43bd8f7ec8fb1 Mon Sep 17 00:00:00 2001 From: qiin Date: Tue, 5 Mar 2024 23:50:30 +0800 Subject: [PATCH] Merge remote-tracking branch 'u/nightly' into feat-combine --- src/display_device/parsed_config.cpp | 1 + src/nvhttp.cpp | 1 + src/platform/linux/cuda.cpp | 43 ++++++++++++++++----------- src_assets/common/assets/web/pin.html | 9 +++++- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/display_device/parsed_config.cpp b/src/display_device/parsed_config.cpp index 20066382deb..165e08f26c0 100644 --- a/src/display_device/parsed_config.cpp +++ b/src/display_device/parsed_config.cpp @@ -31,6 +31,7 @@ namespace display_device { bool parse_resolution_option(const config::video_t &config, const rtsp_stream::launch_session_t &session, parsed_config_t &parsed_config) { const auto resolution_option { static_cast(config.resolution_change) }; + BOOST_LOG(info) << "devices session unique_id: " << session.unique_id; switch (resolution_option) { case parsed_config_t::resolution_change_e::automatic: { if (!session.enable_sops) { diff --git a/src/nvhttp.cpp b/src/nvhttp.cpp index b2cad4fad90..9f24aff8aa2 100644 --- a/src/nvhttp.cpp +++ b/src/nvhttp.cpp @@ -894,6 +894,7 @@ namespace nvhttp { // the moment. This needs to be done before probing encoders as it could // change display device's state. const auto result { display_device::session_t::get().configure_display(config::video, *launch_session) }; + BOOST_LOG(info) << "configure_display"sv << std::begin(map_id_sess)->second; if (!result) { tree.put("root..status_code", result.get_error_code()); tree.put("root..status_message", result.get_error_message()); diff --git a/src/platform/linux/cuda.cpp b/src/platform/linux/cuda.cpp index 5b121c70691..33c939243f2 100644 --- a/src/platform/linux/cuda.cpp +++ b/src/platform/linux/cuda.cpp @@ -247,29 +247,38 @@ namespace cuda { // There's no way to directly go from CUDA to a DRM device, so we'll // use sysfs to look up the DRM device name from the PCI ID. - char pci_bus_id[13]; - CU_CHECK(cdf->cuDeviceGetPCIBusId(pci_bus_id, sizeof(pci_bus_id), device), "Couldn't get CUDA device PCI bus ID"); - BOOST_LOG(debug) << "Found CUDA device with PCI bus ID: "sv << pci_bus_id; + std::array pci_bus_id; + CU_CHECK(cdf->cuDeviceGetPCIBusId(pci_bus_id.data(), pci_bus_id.size(), device), "Couldn't get CUDA device PCI bus ID"); + BOOST_LOG(debug) << "Found CUDA device with PCI bus ID: "sv << pci_bus_id.data(); + + // Linux uses lowercase hexadecimal while CUDA uses uppercase + std::transform(pci_bus_id.begin(), pci_bus_id.end(), pci_bus_id.begin(), + [](char c) { return std::tolower(c); }); // Look for the name of the primary node in sysfs - char sysfs_path[PATH_MAX]; - std::snprintf(sysfs_path, sizeof(sysfs_path), "/sys/bus/pci/devices/%s/drm", pci_bus_id); - fs::path sysfs_dir { sysfs_path }; - for (auto &entry : fs::directory_iterator { sysfs_dir }) { - auto file = entry.path().filename(); - auto filestring = file.generic_u8string(); - if (std::string_view { filestring }.substr(0, 4) != "card"sv) { - continue; - } + try { + char sysfs_path[PATH_MAX]; + std::snprintf(sysfs_path, sizeof(sysfs_path), "/sys/bus/pci/devices/%s/drm", pci_bus_id.data()); + fs::path sysfs_dir { sysfs_path }; + for (auto &entry : fs::directory_iterator { sysfs_dir }) { + auto file = entry.path().filename(); + auto filestring = file.generic_u8string(); + if (std::string_view { filestring }.substr(0, 4) != "card"sv) { + continue; + } - BOOST_LOG(debug) << "Found DRM primary node: "sv << filestring; + BOOST_LOG(debug) << "Found DRM primary node: "sv << filestring; - fs::path dri_path { "/dev/dri"sv }; - auto device_path = dri_path / file; - return open(device_path.c_str(), O_RDWR); + fs::path dri_path { "/dev/dri"sv }; + auto device_path = dri_path / file; + return open(device_path.c_str(), O_RDWR); + } + } + catch (const std::filesystem::filesystem_error &err) { + BOOST_LOG(error) << "Failed to read sysfs: "sv << err.what(); } - BOOST_LOG(error) << "Unable to find DRM device with PCI bus ID: "sv << pci_bus_id; + BOOST_LOG(error) << "Unable to find DRM device with PCI bus ID: "sv << pci_bus_id.data(); return -1; } diff --git a/src_assets/common/assets/web/pin.html b/src_assets/common/assets/web/pin.html index af4b563c571..27dd0727c94 100644 --- a/src_assets/common/assets/web/pin.html +++ b/src_assets/common/assets/web/pin.html @@ -161,9 +161,16 @@

Unpair Clients

} else { this.clients = []; } + + let tmpClients = []; + try { + tmpClients = JSON.parse(this.config.clients) + } catch (error) { + } + this.clients = this.clients.map(client => ({ ...client, - ...(this.config.clients?.find(({uuid}) => uuid = client.uuid)) + ...(tmpClients.find(({uuid}) => uuid = client.uuid)) })) }); },