[Windows] Fix driver version detection of AMD RDNA+ GPU on Windows 10
[xbmc.git] / xbmc / windowing / gbm / drm / DRMObject.h
blobc4200b1a864dce30d989120972ad708283c9808f
1 /*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include <cstddef>
12 #include <cstdint>
13 #include <memory>
14 #include <optional>
15 #include <string_view>
16 #include <vector>
18 #include <xf86drmMode.h>
20 namespace KODI
22 namespace WINDOWING
24 namespace GBM
27 class CDRMObject
29 public:
30 CDRMObject(const CDRMObject&) = delete;
31 CDRMObject& operator=(const CDRMObject&) = delete;
32 virtual ~CDRMObject() = default;
34 std::string GetTypeName() const;
35 std::string GetPropertyName(uint32_t propertyId) const;
37 uint32_t GetId() const { return m_id; }
38 uint32_t GetPropertyId(const std::string& name) const;
39 std::optional<uint64_t> GetPropertyValue(std::string_view name, std::string_view valueName) const;
41 bool SetProperty(const std::string& name, uint64_t value);
42 bool SupportsProperty(const std::string& name);
44 protected:
45 explicit CDRMObject(int fd);
47 bool GetProperties(uint32_t id, uint32_t type);
49 struct DrmModeObjectPropertiesDeleter
51 void operator()(drmModeObjectProperties* p) { drmModeFreeObjectProperties(p); }
54 std::unique_ptr<drmModeObjectProperties, DrmModeObjectPropertiesDeleter> m_props;
56 struct DrmModePropertyResDeleter
58 void operator()(drmModePropertyRes* p) { drmModeFreeProperty(p); }
61 std::vector<std::unique_ptr<drmModePropertyRes, DrmModePropertyResDeleter>> m_propsInfo;
63 int m_fd{-1};
65 private:
66 uint32_t m_id{0};
67 uint32_t m_type{0};
70 } // namespace GBM
71 } // namespace WINDOWING
72 } // namespace KODI