kwin/src/plugins/platforms/drm/drm_gpu.h

152 lines
3.2 KiB
C
Raw Normal View History

/*
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>
2021-02-19 11:59:43 +00:00
#include <QSocketNotifier>
#include <epoxy/egl.h>
#include "drm_buffer.h"
2021-02-15 17:28:58 +00:00
#include "drm_object_plane.h"
struct gbm_device;
namespace KWin
{
2020-11-27 19:57:24 +00:00
class DrmOutput;
class DrmCrtc;
class DrmConnector;
class DrmBackend;
class AbstractEglBackend;
2020-11-27 19:57:24 +00:00
class DrmGpu : public QObject
{
Q_OBJECT
public:
DrmGpu(DrmBackend *backend, QByteArray devNode, int fd, int drmId);
~DrmGpu();
2020-11-27 19:57:24 +00:00
// getters
QVector<DrmOutput*> outputs() const {
return m_outputs;
}
2020-11-27 19:57:24 +00:00
int fd() const {
return m_fd;
}
2020-11-27 19:57:24 +00:00
int drmId() const {
return m_drmId;
}
2020-11-27 19:57:24 +00:00
bool atomicModeSetting() const {
return m_atomicModeSetting;
}
2020-11-27 19:57:24 +00:00
bool useEglStreams() const {
return m_useEglStreams;
}
2020-11-27 19:57:24 +00:00
bool deleteBufferAfterPageFlip() const {
return m_deleteBufferAfterPageFlip;
}
2020-11-27 19:57:24 +00:00
QByteArray devNode() const {
return m_devNode;
}
2020-11-27 19:57:24 +00:00
gbm_device *gbmDevice() const {
return m_gbmDevice;
}
EGLDisplay eglDisplay() const {
return m_eglDisplay;
}
2020-11-27 19:57:24 +00:00
AbstractEglBackend *eglBackend() {
return m_eglBackend;
}
void setGbmDevice(gbm_device *d) {
m_gbmDevice = d;
}
void setEglDisplay(EGLDisplay display) {
m_eglDisplay = display;
}
2020-11-27 19:57:24 +00:00
void setDeleteBufferAfterPageFlip(bool deleteBuffer) {
m_deleteBufferAfterPageFlip = deleteBuffer;
}
2020-11-27 19:57:24 +00:00
DrmDumbBuffer *createBuffer(const QSize &size) const {
return new DrmDumbBuffer(m_fd, size);
}
2020-11-27 19:57:24 +00:00
void setEglBackend(AbstractEglBackend *eglBackend) {
m_eglBackend = eglBackend;
}
2020-11-19 08:52:29 +00:00
/**
* Returns the clock from which presentation timestamps are sourced. The returned value
* can be either CLOCK_MONOTONIC or CLOCK_REALTIME.
*/
clockid_t presentationClock() const;
Q_SIGNALS:
void outputAdded(DrmOutput *output);
void outputRemoved(DrmOutput *output);
void outputEnabled(DrmOutput *output);
void outputDisabled(DrmOutput *output);
2020-11-27 19:57:24 +00:00
protected:
2020-11-27 19:57:24 +00:00
friend class DrmBackend;
void tryAMS();
bool updateOutputs();
2020-11-27 19:57:24 +00:00
private:
2021-02-15 17:28:58 +00:00
DrmPlane *getCompatiblePlane(DrmPlane::TypeIndex typeIndex, DrmCrtc *crtc);
DrmOutput *findOutput(quint32 connector);
2020-11-27 19:57:24 +00:00
DrmBackend* const m_backend;
AbstractEglBackend *m_eglBackend;
2020-11-27 19:57:24 +00:00
const QByteArray m_devNode;
QSize m_cursorSize;
const int m_fd;
const int m_drmId;
bool m_atomicModeSetting;
bool m_useEglStreams;
bool m_deleteBufferAfterPageFlip;
gbm_device* m_gbmDevice;
EGLDisplay m_eglDisplay = EGL_NO_DISPLAY;
2020-11-19 08:52:29 +00:00
clockid_t m_presentationClock;
2021-02-19 11:59:43 +00:00
QSocketNotifier *m_socketNotifier = nullptr;
2020-11-27 19:57:24 +00:00
2021-02-15 17:28:58 +00:00
// all planes: primarys, cursors and overlays
QVector<DrmPlane*> m_planes;
2021-02-15 17:28:58 +00:00
QVector<DrmPlane*> m_unusedPlanes;
// 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