| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2021 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "../igpuinfo.h" |
| 7 | #include "core/idatasource.h" |
| 8 | #include <filesystem> |
| 9 | #include <memory> |
| 10 | #include <string> |
| 11 | #include <units.h> |
| 12 | #include <vector> |
| 13 | |
| 14 | class GPUInfoVRam final : public IGPUInfo::IProvider |
| 15 | { |
| 16 | public: |
| 17 | GPUInfoVRam( |
| 18 | std::unique_ptr<IDataSource<std::string>> &&kernelVersionDataSource, |
| 19 | std::unique_ptr<IDataSource<std::vector<std::string>, std::filesystem::path const>> |
| 20 | &&driverDataSource, |
| 21 | std::unique_ptr<IDataSource<units::data::megabyte_t, std::filesystem::path const>> |
| 22 | &&radeonDataSource, |
| 23 | std::unique_ptr<IDataSource<units::data::megabyte_t, std::filesystem::path const>> |
| 24 | &&amdgpuDataSource) noexcept; |
| 25 | |
| 26 | std::vector<std::pair<std::string, std::string>> |
| 27 | provideInfo(Vendor vendor, int gpuIndex, IGPUInfo::Path const &path, |
| 28 | IHWIDTranslator const &hwIDTranslator) const override; |
| 29 | |
| 30 | std::vector<std::string> |
| 31 | provideCapabilities(Vendor vendor, int, |
| 32 | IGPUInfo::Path const &path) const override; |
| 33 | |
| 34 | private: |
| 35 | std::tuple<int, int, int> readKernelVersion() const; |
| 36 | std::string readDriver(std::filesystem::path const &path) const; |
| 37 | |
| 38 | std::unique_ptr<IDataSource<std::string>> const kernelVersionDataSource_; |
| 39 | std::unique_ptr<IDataSource<std::vector<std::string>, std::filesystem::path const>> const |
| 40 | driverDataSource_; |
| 41 | std::unique_ptr<IDataSource<units::data::megabyte_t, std::filesystem::path const>> const |
| 42 | radeonDataSource_; |
| 43 | std::unique_ptr<IDataSource<units::data::megabyte_t, std::filesystem::path const>> const |
| 44 | amdgpuDataSource_; |
| 45 | |
| 46 | static bool registered_; |
| 47 | }; |