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

105 lines
2.5 KiB
C
Raw Normal View History

2020-08-02 22:22:19 +00:00
/*
KWin - the KDE window manager
This file is part of the KDE project.
2020-08-02 22:22:19 +00:00
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
2020-08-02 22:22:19 +00:00
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_DRM_OUTPUT_H
#define KWIN_DRM_OUTPUT_H
#include "abstract_wayland_output.h"
#include "drm_pointer.h"
#include "drm_object.h"
#include "drm_object_plane.h"
#include <QObject>
#include <QPoint>
#include <QSize>
#include <QVector>
2021-03-22 14:46:09 +00:00
#include <QSharedPointer>
#include <xf86drmMode.h>
namespace KWin
{
class DrmBackend;
class DrmBuffer;
class DrmDumbBuffer;
class DrmPlane;
class DrmConnector;
class DrmCrtc;
class Cursor;
class DrmGpu;
class DrmPipeline;
class KWIN_EXPORT DrmOutput : public AbstractWaylandOutput
{
Q_OBJECT
public:
///deletes the output, calling this whilst a page flip is pending will result in an error
~DrmOutput() override;
2020-11-19 08:52:29 +00:00
RenderLoop *renderLoop() const override;
bool showCursor();
bool hideCursor();
bool updateCursor();
bool moveCursor();
bool present(const QSharedPointer<DrmBuffer> &buffer, QRegion damagedRegion);
void pageFlipped();
bool isDpmsEnabled() const;
DrmPipeline *pipeline() const;
DrmBuffer *currentBuffer() const;
[platforms/drm] EGLStream DRM Backend Initial Implementation Summary: This is the initial implementation of a DRM backend based on the EGLDevice, EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using their proprietary driver. The new backend will be used if the environment variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to create an EGLDevice based on the DRM device currently in use and create EGLOutputs and EGLStreams for any attached displays. These are used to control presentation of the final composited frame. Additionally, it will register the wl_eglstream_controller Wayland interface so that native EGL windows created by clients can be attached to an EGLStream allowing buffer contents to be shared with the compositor as a GL texture. At this time there are two known bugs in the NVIDIA driver's EGL implementation affecting desktop functionality. The first can result in tooltip windows drawn by plasmashell to contain incorrect contents. The second prevents KWayland from being able to query the format of EGLStream-backed buffers which interferes with the blur effect. Fixes for both of these are currently in development and should appear in an upcoming NVIDIA driver release. Additionally, hardware cursors are currently not supported with this backend. Enabling them causes the desktop to intermittently hang for several seconds. This is also likely a bug in the NVIDIA DRM-KMS implementation but the root cause is still under investigation. Test Plan: On a system with an NVIDIA graphics card running a recent release of their proprietary driver * Ensure the nvidia_drm kernel module is loaded with the option "modeset=1" ("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y") * Ensure EGL external platform support is installed https://github.com/NVIDIA/eglexternalplatform * Ensure KWin was build with the CMake option KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default) * Start a plasma wayland session with the environment variable KWIN_DRM_USE_EGL_STREAMS set * Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL driver is in use (as opposed to Mesa / llvmpipe). * Desktop should be fully functional and perform smoothly. Reviewers: #kwin, romangg, davidedmundson Reviewed By: #kwin, romangg, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
bool initCursor(const QSize &cursorSize);
/**
* Drm planes might be capable of realizing the current output transform without usage
* of compositing. This is a getter to query the current state of that
*
* @return true if the hardware realizes the transform without further assistance
*/
bool hardwareTransforms() const;
2020-11-27 19:57:24 +00:00
DrmGpu *gpu() {
return m_gpu;
}
private:
friend class DrmGpu;
friend class DrmBackend;
DrmOutput(DrmBackend *backend, DrmGpu* gpu, DrmPipeline *pipeline);
void initOutputDevice();
bool isCurrentMode(const drmModeModeInfo *mode) const;
void updateEnablement(bool enable) override;
void setDrmDpmsMode(DpmsMode mode);
void setDpmsMode(DpmsMode mode) override;
void updateMode(int modeIndex) override;
2020-12-15 20:20:10 +00:00
void updateMode(uint32_t width, uint32_t height, uint32_t refreshRate);
void updateTransform(Transform transform) override;
int gammaRampSize() const override;
bool setGammaRamp(const GammaRamp &gamma) override;
void setOverscan(uint32_t overscan) override;
DrmBackend *m_backend;
DrmGpu *m_gpu;
DrmPipeline *m_pipeline;
2020-11-19 08:52:29 +00:00
RenderLoop *m_renderLoop;
QSharedPointer<DrmDumbBuffer> m_cursor;
bool m_pageFlipPending = false;
QTimer m_turnOffTimer;
};
}
Q_DECLARE_METATYPE(KWin::DrmOutput*)
#endif