| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/info/common/gpuinforevision.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "gpuinforevision.h"cxx . . $ `<file>/src/core/info/common/gpuinforevision.h`/ |
| 5 | |
| 6 | #include "../infoproviderregistry.h"cxx . . $ `<file>/src/core/info/infoproviderregistry.h`/ |
| 7 | #include "common/fileutils.h"cxx . . $ `<file>/src/common/fileutils.h`/ |
| 8 | #include "common/stringutils.h"cxx . . $ `<file>/src/common/stringutils.h`/ |
| 9 | #include <algorithm> |
| 10 | #include <cctype> |
| 11 | #include <spdlog/spdlog.h> |
| 12 | #include <utility> |
| 13 | |
| 14 | class GPUInfoRevisionDataSourcecxx . . $ GPUInfoRevisionDataSource# |
| 15 | : public IDataSourcecxx . . $ IDataSource#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# const> |
| 16 | { |
| 17 | public: |
| 18 | stdcxx . . $ std/::stringcxx . . $ std/string# sourcecxx . . $ GPUInfoRevisionDataSource#source(219584694fe2b248).() const override |
| 19 | { |
| 20 | return "revision"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 21 | } |
| 22 | |
| 23 | bool readcxx . . $ GPUInfoRevisionDataSource#read(6aed87d900484a21).(stdcxx . . $ std/::stringcxx . . $ std/string# &data, stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# const &path) override |
| 24 | { |
| 25 | auto const filePath = path /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). sourcecxx . . $ std/filesystem/__cxx11/path#path(2f6c7066048c5333).(); |
| 26 | auto const lines = Utilscxx . . $ Utils/::Filecxx . . $ Utils/File/::readFileLinescxx . . $ Utils/File/readFileLines(951e54d16e2206f).(filePath); |
| 27 | if (!lines.emptycxx . . $ std/vector#empty(3482b152b9333168).()) { |
| 28 | data =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). lines.frontcxx . . $ std/vector#front(af0004c3ce7cab93).(); |
| 29 | return true; |
| 30 | } |
| 31 | |
| 32 | SPDLOG_WARNcxx . . $ `<external>/13613935168682455490/spdlog.h:329:13`!("Cannot retrieve device revision from {}", filePath.c_str()); |
| 33 | return false; |
| 34 | } |
| 35 | }; |
| 36 | |
| 37 | GPUInfoRevisioncxx . . $ GPUInfoRevision#::GPUInfoRevisioncxx . . $ GPUInfoRevision#GPUInfoRevision(50e9a1d442764874).( |
| 38 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IDataSourcecxx . . $ IDataSource#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# const>> |
| 39 | &&dataSource) noexcept |
| 40 | : dataSource_cxx . . $ GPUInfoRevision#dataSource_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(dataSource)) |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>> |
| 45 | GPUInfoRevisioncxx . . $ GPUInfoRevision#::provideInfocxx . . $ GPUInfoRevision#provideInfo(5b65f7e996e13d80).(Vendorcxx . . $ Vendor#, int, IGPUInfocxx . . $ IGPUInfo#::Pathcxx . . $ IGPUInfo#Path# const &path, |
| 46 | IHWIDTranslatorcxx . . $ IHWIDTranslator# const &) const |
| 47 | { |
| 48 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>> infocxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 49 | |
| 50 | stdcxx . . $ std/::stringcxx . . $ std/string# datacxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 51 | if (dataSource_cxx . . $ GPUInfoRevision#dataSource_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).readcxx . . $ IDataSource#read(ad81cd1bcc32f58b).(data, path.syscxx . . $ IGPUInfo#Path#sys.)) { |
| 52 | stdcxx . . $ std/::stringcxx . . $ std/string# rev(Utilscxx . . $ Utils/::Stringcxx . . $ Utils/String/::cleanPrefixcxx . . $ Utils/String/cleanPrefix(203b42cd324c6c40).(data, "0x"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 53 | stdcxx . . $ std/::transformcxx . . $ std/transform(da30451c4a040264).(rev.cbegincxx . . $ std/__cxx11/basic_string#cbegin(a865d278ca20c908).(), rev.cendcxx . . $ std/__cxx11/basic_string#cend(a865d278ca20c908).(), rev.begincxx . . $ std/__cxx11/basic_string#begin(fd29ebd65481b919).(), ::toupper); |
| 54 | info.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(IGPUInfocxx . . $ IGPUInfo#::Keyscxx . . $ IGPUInfo#Keys#::revisioncxx . . $ IGPUInfo#Keys#revision., stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(rev)); |
| 55 | } |
| 56 | |
| 57 | return infocxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 58 | } |
| 59 | |
| 60 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> |
| 61 | GPUInfoRevisioncxx . . $ GPUInfoRevision#::provideCapabilitiescxx . . $ GPUInfoRevision#provideCapabilities(da28437f5803dad2).(Vendorcxx . . $ Vendor#, int, IGPUInfocxx . . $ IGPUInfo#::Pathcxx . . $ IGPUInfo#Path# const &) const |
| 62 | { |
| 63 | return {cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).}; |
| 64 | } |
| 65 | |
| 66 | bool GPUInfoRevisioncxx . . $ GPUInfoRevision#::registered_cxx . . $ GPUInfoRevision#registered_. = |
| 67 | InfoProviderRegistrycxx . . $ InfoProviderRegistry#::addcxx . . $ InfoProviderRegistry#add(2c04d579dc484cde).(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<GPUInfoRevisioncxx . . $ GPUInfoRevision#>( |
| 68 | stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<GPUInfoRevisionDataSourcecxx . . $ GPUInfoRevisionDataSource#>())); |