File indexing completed on 2024-06-09 05:25:22

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2016 Roman Gilg <subdiff@gmail.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #pragma once
0010 
0011 #include <QByteArray>
0012 #include <QList>
0013 #include <QMap>
0014 
0015 #include <vector>
0016 
0017 // drm
0018 #include <xf86drmMode.h>
0019 
0020 #include "drm_pointer.h"
0021 #include "drm_property.h"
0022 
0023 namespace KWin
0024 {
0025 
0026 class DrmBackend;
0027 class DrmGpu;
0028 class DrmOutput;
0029 class DrmAtomicCommit;
0030 
0031 class DrmPropertyList
0032 {
0033 public:
0034     void addProperty(DrmUniquePtr<drmModePropertyRes> &&prop, uint64_t value);
0035     std::optional<std::pair<DrmUniquePtr<drmModePropertyRes>, uint64_t>> takeProperty(const QByteArray &name);
0036 
0037 private:
0038     std::vector<std::pair<DrmUniquePtr<drmModePropertyRes>, uint64_t>> m_properties;
0039 };
0040 
0041 class DrmObject
0042 {
0043 public:
0044     virtual ~DrmObject() = default;
0045     DrmObject(const DrmObject &) = delete;
0046 
0047     /**
0048      * Must be called to query necessary data directly after creation.
0049      * @return true when initializing was successful
0050      */
0051     bool init();
0052 
0053     /**
0054      * Set the properties in such a way that this resource won't be used anymore
0055      */
0056     virtual void disable(DrmAtomicCommit *commit) = 0;
0057 
0058     virtual bool updateProperties() = 0;
0059 
0060     uint32_t id() const;
0061     DrmGpu *gpu() const;
0062     uint32_t type() const;
0063     QString typeName() const;
0064 
0065 protected:
0066     DrmObject(DrmGpu *gpu, uint32_t objectId, uint32_t objectType);
0067 
0068     DrmPropertyList queryProperties() const;
0069 
0070 private:
0071     DrmGpu *m_gpu;
0072     const uint32_t m_id;
0073     const uint32_t m_objectType;
0074 };
0075 
0076 }
0077 
0078 QDebug operator<<(QDebug stream, const KWin::DrmObject *);