drm_gpu.h 2.43 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*
    KWin - the KDE window manager
    This file is part of the KDE project.

    SPDX-FileCopyrightText: 2020 Xaver Hugl <xaver.hugl@gmail.com>

    SPDX-License-Identifier: GPL-2.0-or-later
*/

#ifndef DRM_GPU_H
#define DRM_GPU_H

#include <qobject.h>
#include <QVector>

16
17
18
#include <epoxy/egl.h>
#include <fixx11h.h>

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "drm_buffer.h"

struct gbm_device;

namespace KWin
{
    
class DrmOutput;
class DrmPlane;
class DrmCrtc;
class DrmConnector;
class DrmBackend;
class AbstractEglBackend;
    
class DrmGpu : public QObject
{
    Q_OBJECT
public:
    DrmGpu(DrmBackend *backend, QByteArray devNode, int fd, int drmId);
    ~DrmGpu();
    
    // getters
    QVector<DrmOutput*> outputs() const {
        return m_outputs;
    }
    
    int fd() const {
        return m_fd;
    }
    
    int drmId() const {
        return m_drmId;
    }
    
    bool atomicModeSetting() const {
        return m_atomicModeSetting;
    }
    
    QByteArray devNode() const {
        return m_devNode;
    }
    
    gbm_device *gbmDevice() const {
        return m_gbmDevice;
    }
64
65
66
67

    EGLDisplay eglDisplay() const {
        return m_eglDisplay;
    }
68
69
70
71
72
73
74
75
    
    QVector<DrmPlane*> planes() const {
        return m_planes;
    }
    
    void setGbmDevice(gbm_device *d) {
        m_gbmDevice = d;
    }
76
77
78
79

    void setEglDisplay(EGLDisplay display) {
        m_eglDisplay = display;
    }
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
    
    DrmDumbBuffer *createBuffer(const QSize &size) const {
        return new DrmDumbBuffer(m_fd, size);
    }
    
Q_SIGNALS:
    void outputAdded(DrmOutput *output);
    void outputRemoved(DrmOutput *output);
    void outputEnabled(DrmOutput *output);
    void outputDisabled(DrmOutput *output);
    
protected:
    
    friend class DrmBackend;
    void tryAMS();
    bool updateOutputs();
    
private:
    DrmOutput *findOutput(quint32 connector);
    
    DrmBackend* const m_backend;
    
    const QByteArray m_devNode;
103
    QSize m_cursorSize;
104
105
106
107
108
    const int m_fd;
    const int m_drmId;
    bool m_atomicModeSetting;
    bool m_useEglStreams;
    gbm_device* m_gbmDevice;
109
    EGLDisplay m_eglDisplay = EGL_NO_DISPLAY;
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
    
// all available planes: primarys, cursors and overlays
    QVector<DrmPlane*> m_planes;
    QVector<DrmPlane*> m_overlayPlanes;
    // crtcs
    QVector<DrmCrtc*> m_crtcs;
    // connectors
    QVector<DrmConnector*> m_connectors;
    // active output pipelines (planes + crtc + encoder + connector)
    QVector<DrmOutput*> m_outputs;
};

}

#endif // DRM_GPU_H