KWin
Loading...
Searching...
No Matches
drm_crtc.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2016 Roman Gilg <subdiff@gmail.com>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#include "drm_crtc.h"
10#include "drm_backend.h"
11#include "drm_buffer.h"
12#include "drm_commit.h"
13#include "drm_gpu.h"
14#include "drm_output.h"
15#include "drm_pointer.h"
16
17namespace KWin
18{
19
20DrmCrtc::DrmCrtc(DrmGpu *gpu, uint32_t crtcId, int pipeIndex, DrmPlane *primaryPlane, DrmPlane *cursorPlane)
21 : DrmObject(gpu, crtcId, DRM_MODE_OBJECT_CRTC)
22 , modeId(this, QByteArrayLiteral("MODE_ID"))
23 , active(this, QByteArrayLiteral("ACTIVE"))
24 , vrrEnabled(this, QByteArrayLiteral("VRR_ENABLED"))
25 , gammaLut(this, QByteArrayLiteral("GAMMA_LUT"))
26 , gammaLutSize(this, QByteArrayLiteral("GAMMA_LUT_SIZE"))
27 , ctm(this, QByteArrayLiteral("CTM"))
28 , degammaLut(this, QByteArrayLiteral("DEGAMMA_LUT"))
29 , degammaLutSize(this, QByteArrayLiteral("DEGAMMA_LUT_SIZE"))
30 , m_crtc(drmModeGetCrtc(gpu->fd(), crtcId))
31 , m_pipeIndex(pipeIndex)
32 , m_primaryPlane(primaryPlane)
33 , m_cursorPlane(cursorPlane)
34{
35}
36
38{
39 if (!m_crtc) {
40 return false;
41 }
43 modeId.update(props);
44 active.update(props);
45 vrrEnabled.update(props);
46 gammaLut.update(props);
47 gammaLutSize.update(props);
48 ctm.update(props);
49 degammaLut.update(props);
51
52 return !gpu()->atomicModeSetting() || (modeId.isValid() && active.isValid());
53}
54
56{
57 m_crtc.reset(drmModeGetCrtc(gpu()->fd(), id()));
58 return m_crtc->mode;
59}
60
62{
63 return m_pipeIndex;
64}
65
66std::shared_ptr<DrmFramebuffer> DrmCrtc::current() const
67{
68 return m_currentBuffer;
69}
70
71void DrmCrtc::setCurrent(const std::shared_ptr<DrmFramebuffer> &buffer)
72{
73 m_currentBuffer = buffer;
74}
75
77{
78 if (gpu()->atomicModeSetting()) {
79 // limit atomic gamma ramp to 4096 to work around https://gitlab.freedesktop.org/drm/intel/-/issues/3916
80 if (gammaLutSize.isValid() && gammaLutSize.value() <= 4096) {
81 return gammaLutSize.value();
82 }
83 }
84 return m_crtc->gamma_size;
85}
86
88{
89 return m_primaryPlane;
90}
91
93{
94 return m_cursorPlane;
95}
96
98{
99 commit->addProperty(active, 0);
100 commit->addProperty(modeId, 0);
101}
102
104{
105 if (m_currentBuffer) {
106 m_currentBuffer->releaseBuffer();
107 }
108}
109}
void addProperty(const DrmProperty &prop, uint64_t value)
DrmProperty active
Definition drm_crtc.h:44
void releaseCurrentBuffer()
Definition drm_crtc.cpp:103
DrmProperty modeId
Definition drm_crtc.h:43
std::shared_ptr< DrmFramebuffer > current() const
Definition drm_crtc.cpp:66
DrmProperty gammaLutSize
Definition drm_crtc.h:47
DrmCrtc(DrmGpu *gpu, uint32_t crtcId, int pipeIndex, DrmPlane *primaryPlane, DrmPlane *cursorPlane)
Definition drm_crtc.cpp:20
DrmProperty ctm
Definition drm_crtc.h:48
int pipeIndex() const
Definition drm_crtc.cpp:61
DrmPlane * primaryPlane() const
Definition drm_crtc.cpp:87
DrmProperty vrrEnabled
Definition drm_crtc.h:45
DrmProperty gammaLut
Definition drm_crtc.h:46
void disable(DrmAtomicCommit *commit) override
Definition drm_crtc.cpp:97
DrmProperty degammaLutSize
Definition drm_crtc.h:50
DrmProperty degammaLut
Definition drm_crtc.h:49
int gammaRampSize() const
Definition drm_crtc.cpp:76
DrmPlane * cursorPlane() const
Definition drm_crtc.cpp:92
drmModeModeInfo queryCurrentMode()
Definition drm_crtc.cpp:55
void setCurrent(const std::shared_ptr< DrmFramebuffer > &buffer)
Definition drm_crtc.cpp:71
bool updateProperties() override
Definition drm_crtc.cpp:37
bool atomicModeSetting() const
Definition drm_gpu.cpp:658
DrmPropertyList queryProperties() const
DrmGpu * gpu() const
void update(DrmPropertyList &propertyList)
uint64_t value() const
bool isValid() const
drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
Definition mock_drm.cpp:486