File indexing completed on 2025-04-20 10:57:33

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 "drm_object.h"
0012 
0013 #include <QPoint>
0014 #include <memory>
0015 
0016 namespace KWin
0017 {
0018 
0019 class DrmBackend;
0020 class DrmFramebuffer;
0021 class DrmDumbBuffer;
0022 class GammaRamp;
0023 class DrmGpu;
0024 class DrmPlane;
0025 
0026 class DrmCrtc : public DrmObject
0027 {
0028 public:
0029     DrmCrtc(DrmGpu *gpu, uint32_t crtcId, int pipeIndex, DrmPlane *primaryPlane, DrmPlane *cursorPlane);
0030 
0031     enum class PropertyIndex : uint32_t {
0032         ModeId = 0,
0033         Active,
0034         VrrEnabled,
0035         Gamma_LUT,
0036         Gamma_LUT_Size,
0037         CTM,
0038         Count
0039     };
0040 
0041     bool init() override;
0042     void disable() override;
0043 
0044     int pipeIndex() const;
0045     int gammaRampSize() const;
0046     DrmPlane *primaryPlane() const;
0047     DrmPlane *cursorPlane() const;
0048     drmModeModeInfo queryCurrentMode();
0049 
0050     std::shared_ptr<DrmFramebuffer> current() const;
0051     std::shared_ptr<DrmFramebuffer> next() const;
0052     void setCurrent(const std::shared_ptr<DrmFramebuffer> &buffer);
0053     void setNext(const std::shared_ptr<DrmFramebuffer> &buffer);
0054     void flipBuffer();
0055     void releaseBuffers();
0056 
0057 private:
0058     DrmUniquePtr<drmModeCrtc> m_crtc;
0059     std::shared_ptr<DrmFramebuffer> m_currentBuffer;
0060     std::shared_ptr<DrmFramebuffer> m_nextBuffer;
0061     int m_pipeIndex;
0062     DrmPlane *m_primaryPlane;
0063     DrmPlane *m_cursorPlane;
0064 };
0065 
0066 }