/* KWin - the KDE window manager This file is part of the KDE project. SPDX-FileCopyrightText: 2020 Xaver Hugl SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef DRM_GPU_H #define DRM_GPU_H #include #include #include #include #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 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; } EGLDisplay eglDisplay() const { return m_eglDisplay; } QVector planes() const { return m_planes; } void setGbmDevice(gbm_device *d) { m_gbmDevice = d; } void setEglDisplay(EGLDisplay display) { m_eglDisplay = display; } 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; QSize m_cursorSize; const int m_fd; const int m_drmId; bool m_atomicModeSetting; bool m_useEglStreams; gbm_device* m_gbmDevice; EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; // all available planes: primarys, cursors and overlays QVector m_planes; QVector m_overlayPlanes; // crtcs QVector m_crtcs; // connectors QVector m_connectors; // active output pipelines (planes + crtc + encoder + connector) QVector m_outputs; }; } #endif // DRM_GPU_H