From b0e3ac20ed9e98cfcfc62e3578efd6ef7443858e Mon Sep 17 00:00:00 2001 From: Pier Luigi Fiorini Date: Sat, 30 Sep 2023 09:13:56 +0200 Subject: [PATCH] Device integration for DRM/KMS Closes: #43 --- CMakeLists.txt | 3 + features.cmake | 29 +++ .../deviceintegration/drm/CMakeLists.txt | 38 ++++ src/plugins/deviceintegration/drm/drm.json | 3 + .../deviceintegration/drm/drmbackend.cpp | 197 ++++++++++++++++++ .../deviceintegration/drm/drmbackend.h | 64 ++++++ .../deviceintegration/drm/drmcursor.cpp | 46 ++++ src/plugins/deviceintegration/drm/drmcursor.h | 27 +++ src/plugins/deviceintegration/drm/drmgpu.cpp | 73 +++++++ src/plugins/deviceintegration/drm/drmgpu.h | 47 +++++ .../deviceintegration/drm/drmintegration.cpp | 104 +++++++++ .../deviceintegration/drm/drmintegration.h | 44 ++++ .../drm/drmintegrationplugin.cpp | 23 ++ .../drm/drmintegrationplugin.h | 24 +++ .../deviceintegration/drm/drmoutput.cpp | 22 ++ src/plugins/deviceintegration/drm/drmoutput.h | 23 ++ .../deviceintegration/drm/drmwindow.cpp | 19 ++ src/plugins/deviceintegration/drm/drmwindow.h | 28 +++ 18 files changed, 814 insertions(+) create mode 100644 src/plugins/deviceintegration/drm/CMakeLists.txt create mode 100644 src/plugins/deviceintegration/drm/drm.json create mode 100644 src/plugins/deviceintegration/drm/drmbackend.cpp create mode 100644 src/plugins/deviceintegration/drm/drmbackend.h create mode 100644 src/plugins/deviceintegration/drm/drmcursor.cpp create mode 100644 src/plugins/deviceintegration/drm/drmcursor.h create mode 100644 src/plugins/deviceintegration/drm/drmgpu.cpp create mode 100644 src/plugins/deviceintegration/drm/drmgpu.h create mode 100644 src/plugins/deviceintegration/drm/drmintegration.cpp create mode 100644 src/plugins/deviceintegration/drm/drmintegration.h create mode 100644 src/plugins/deviceintegration/drm/drmintegrationplugin.cpp create mode 100644 src/plugins/deviceintegration/drm/drmintegrationplugin.h create mode 100644 src/plugins/deviceintegration/drm/drmoutput.cpp create mode 100644 src/plugins/deviceintegration/drm/drmoutput.h create mode 100644 src/plugins/deviceintegration/drm/drmwindow.cpp create mode 100644 src/plugins/deviceintegration/drm/drmwindow.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 78d28b3c..53862858 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,9 @@ if(FEATURE_aurora_qpa) add_subdirectory(src/plugins/platforms/eglfs/deviceintegration/eglfs_x11) endif() endif() +if(FEATURE_aurora_deviceintegration_drm) + add_subdirectory(src/plugins/deviceintegration/drm) +endif() if(FEATURE_aurora_deviceintegration_wayland) add_subdirectory(src/plugins/deviceintegration/wayland) endif() diff --git a/features.cmake b/features.cmake index 2adba8e9..8eafdab3 100644 --- a/features.cmake +++ b/features.cmake @@ -471,6 +471,35 @@ if(FEATURE_aurora_vulkan_server_buffer) endif() set(LIRI_FEATURE_aurora_vulkan_server_buffer "$") +# Device Integration: drm +option(FEATURE_aurora_deviceintegration_drm "Device Integration: drm" ON) +if(FEATURE_aurora_deviceintegration_drm) + find_package(EGL QUIET) + + if(NOT TARGET EGL::EGL) + message(WARNING "You need EGL for Aurora::DeviceIntegration::DRM") + set(FEATURE_aurora_deviceintegration_drm OFF) + endif() + if(NOT TARGET PkgConfig::Libudev) + message(WARNING "You need udev for Aurora::DeviceIntegration::DRM") + set(FEATURE_aurora_deviceintegration_drm OFF) + endif() + if(NOT TARGET PkgConfig::Libinput) + message(WARNING "You need libinput for Aurora::DeviceIntegration::DRM") + set(FEATURE_aurora_deviceintegration_drm OFF) + endif() + if(NOT TARGET PkgConfig::Libdrm) + message(WARNING "You need libdrm for Aurora::DeviceIntegration::DRM") + set(FEATURE_aurora_deviceintegration_drm OFF) + endif() + if(NOT TARGET PkgConfig::Gbm) + message(WARNING "You need gbm for Aurora::DeviceIntegration::DRM") + set(FEATURE_aurora_deviceintegration_drm OFF) + endif() +endif() +add_feature_info("Aurora::DeviceIntegration::DRM" FEATURE_aurora_deviceintegration_drm "Build DRM/KMS device integration") +set(LIRI_FEATURE_aurora_deviceintegration_drm "$") + # Device Integration: wayland option(FEATURE_aurora_deviceintegration_wayland "Device Integration: wayland" ON) if(FEATURE_aurora_deviceintegration_wayland) diff --git a/src/plugins/deviceintegration/drm/CMakeLists.txt b/src/plugins/deviceintegration/drm/CMakeLists.txt new file mode 100644 index 00000000..f6107711 --- /dev/null +++ b/src/plugins/deviceintegration/drm/CMakeLists.txt @@ -0,0 +1,38 @@ +include(ECMQtDeclareLoggingCategory) +ecm_qt_declare_logging_category( + AuroraDeviceIntegrationDrm_SOURCES + HEADER "drmloggingcategories.h" + IDENTIFIER "Aurora::Platform::gLcDrm" + CATEGORY_NAME "aurora.platform.drm" + DEFAULT_SEVERITY "Info" + DESCRIPTION "Aurora device integration for DRM/KMS" +) + +liri_add_plugin(AuroraDeviceIntegrationDrm + TYPE + "aurora/deviceintegration" + OUTPUT_NAME + drm + SOURCES + drm.json + drmbackend.cpp drmbackend.h + drmcursor.cpp drmcursor.h + drmgpu.cpp drmgpu.h + drmintegration.cpp drmintegration.h + drmintegrationplugin.cpp drmintegrationplugin.h + drmoutput.cpp drmoutput.h + drmwindow.cpp drmwindow.h + ${AuroraDeviceIntegrationDrm_SOURCES} + PUBLIC_LIBRARIES + Qt::Core + Qt::Gui + Liri::AuroraCore + Liri::AuroraPlatform + Liri::AuroraPlatformPrivate + Liri::AuroraUdev + EGL::EGL + PkgConfig::Libdrm + PkgConfig::Gbm +) + +liri_finalize_plugin(AuroraDeviceIntegrationDrm) diff --git a/src/plugins/deviceintegration/drm/drm.json b/src/plugins/deviceintegration/drm/drm.json new file mode 100644 index 00000000..735ca9ae --- /dev/null +++ b/src/plugins/deviceintegration/drm/drm.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "drm" ] +} diff --git a/src/plugins/deviceintegration/drm/drmbackend.cpp b/src/plugins/deviceintegration/drm/drmbackend.cpp new file mode 100644 index 00000000..92f3736e --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmbackend.cpp @@ -0,0 +1,197 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: GPL-3.0-or-later + +#include + +#include "drmbackend.h" +#include "drmgpu.h" +#include "drmloggingcategories.h" +#include "drmoutput.h" + +#include + +#include +#include +#include +#include + +#ifndef EGL_EXT_platform_base +typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform, + void *native_display, + const EGLint *attrib_list); +#endif + +#ifndef EGL_PLATFORM_GBM_KHR +# define EGL_PLATFORM_GBM_KHR 0x31D7 +#endif + +namespace Aurora { + +namespace Platform { + +Q_GLOBAL_STATIC(DrmBackend, gDrmBackend) + +DrmBackend::DrmBackend(QObject *parent) + : QObject(parent) + , m_session(Session::create(Session::Type::Logind, this)) + , m_udev(new Aurora::PlatformSupport::Udev()) +{ +} + +DrmBackend::~DrmBackend() +{ + if (m_udev) { + delete m_udev; + m_udev = nullptr; + } +} + +Session *DrmBackend::session() const +{ + return m_session; +} + +EGLDisplay DrmBackend::eglDisplay() const +{ + return m_eglDisplay; +} + +EGLNativeDisplayType DrmBackend::platformDisplay() const +{ + if (m_gpu) + return reinterpret_cast(m_gpu->gbmDevice()); + return EGL_CAST(EGLNativeDisplayType, 0); +} + +DrmGpu *DrmBackend::primaryGpu() const +{ + return m_gpu; +} + +void DrmBackend::initialize() +{ + if (m_initialized) + return; + + m_initialized = true; + + // Session + connect(m_session, &Session::devicePaused, this, [this](dev_t deviceId) { + if (auto *gpu = findGpu(deviceId)) + gpu->setActive(false); + }); + connect(m_session, &Session::deviceResumed, this, [this](dev_t deviceId) { + if (auto *gpu = findGpu(deviceId)) + gpu->setActive(true); + }); + + // Find all GPUs + Aurora::PlatformSupport::UdevEnumerate enumerate( + Aurora::PlatformSupport::UdevDevice::PrimaryVideoDevice + | Aurora::PlatformSupport::UdevDevice::GenericVideoDevice, + m_udev); + auto udevDevices = enumerate.scan(); + if (Q_UNLIKELY(udevDevices.isEmpty())) + qFatal("Could not find DRM device!"); + + // Create GPUs + qCDebug(gLcDrm) << "Found the following video devices:"; + for (auto *udevDevice : qAsConst(udevDevices)) { + if (udevDevice->seat() == m_session->seat()) { + const auto path = udevDevice->deviceNode(); + qCDebug(gLcDrm) << '\t' << path.toLocal8Bit().constData(); + addGpu(path); + } + } + + if (Q_UNLIKELY(m_gpus.isEmpty())) + qFatal("No suitable DRM device have been found"); + + // Select the first one + m_gpu = m_gpus.first(); + + // Create EGL display + createDisplay(); +} + +void DrmBackend::destroy() +{ +} + +DrmBackend *DrmBackend::instance() +{ + return gDrmBackend(); +} + +DrmGpu *DrmBackend::addGpu(const QString &path) +{ + // Open the DRM device + int fd = m_session->openRestricted(path); + if (fd < 0) { + qCWarning(gLcDrm) << "Failed to open DRM device" << path; + return nullptr; + } + + // Make a simpel DRM call to check if the device is usable + drmModeResPtr resources = drmModeGetResources(fd); + if (!resources) { + qCDebug(gLcDrm) << "Skipping KMS incapable DRM device" << path; + m_session->closeRestricted(fd); + return nullptr; + } + drmModeFreeResources(resources); + + struct stat sbuf; + if (fstat(fd, &sbuf) < 0) { + qCDebug(gLcDrm, "Failed to fstat \"%s\": %s", qPrintable(path), strerror(errno)); + m_session->closeRestricted(fd); + return nullptr; + } + + qCInfo(gLcDrm) << "Adding DRM device:" << path; + + auto *gpu = new DrmGpu(path, fd, sbuf.st_rdev); + m_gpus.append(gpu); + emit gpuAdded(gpu); + return gpu; +} + +DrmGpu *DrmBackend::findGpu(dev_t deviceId) const +{ + auto it = std::find_if(m_gpus.begin(), m_gpus.end(), + [deviceId](const auto *gpu) { return gpu->deviceId() == deviceId; }); + return it == m_gpus.end() ? nullptr : *it; +} + +void DrmBackend::createDisplay() +{ + EGLNativeDisplayType nativeDisplay = platformDisplay(); + + PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay = nullptr; + const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + if (extensions + && (strstr(extensions, "EGL_KHR_platform_gbm") + || strstr(extensions, "EGL_MESA_platform_gbm"))) { + getPlatformDisplay = reinterpret_cast( + eglGetProcAddress("eglGetPlatformDisplayEXT")); + } + + if (getPlatformDisplay) { + m_eglDisplay = getPlatformDisplay(EGL_PLATFORM_GBM_KHR, nativeDisplay, nullptr); + } else { + qCDebug(gLcDrm, "No eglGetPlatformDisplay for GBM, falling back to eglGetDisplay"); + m_eglDisplay = eglGetDisplay(nativeDisplay); + } +} + +void DrmBackend::addOutput(DrmOutput *output) +{ +} + +void DrmBackend::removeOutput(DrmOutput *output) +{ +} + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmbackend.h b/src/plugins/deviceintegration/drm/drmbackend.h new file mode 100644 index 00000000..4117af42 --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmbackend.h @@ -0,0 +1,64 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include + +#include +#include + +#include + +namespace Aurora { + +namespace Platform { + +class DrmGpu; +class DrmOutput; + +class DrmBackend : public QObject +{ + Q_OBJECT +public: + explicit DrmBackend(QObject *parent = nullptr); + ~DrmBackend(); + + Session *session() const; + + EGLDisplay eglDisplay() const; + EGLNativeDisplayType platformDisplay() const; + + DrmGpu *primaryGpu() const; + + void initialize(); + void destroy(); + + static DrmBackend *instance(); + +signals: + void gpuAdded(DrmGpu *gpu); + void gpuRemoved(DrmGpu *gpu); + +private: + bool m_initialized = false; + Session *m_session = nullptr; + Aurora::PlatformSupport::Udev *m_udev = nullptr; + DrmGpu *m_gpu = nullptr; + QList m_gpus; + EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; + + DrmGpu *findGpu(dev_t deviceId) const; + DrmGpu *addGpu(const QString &path); + + void createDisplay(); + +private slots: + void addOutput(DrmOutput *output); + void removeOutput(DrmOutput *output); + void updateOutputs(); +}; + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmcursor.cpp b/src/plugins/deviceintegration/drm/drmcursor.cpp new file mode 100644 index 00000000..85a7c624 --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmcursor.cpp @@ -0,0 +1,46 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "drmbackend.h" +#include "drmcursor.h" +#include "drmgpu.h" +#include "drmloggingcategories.h" + +#include +#include +#include + +#ifndef DRM_CAP_CURSOR_WIDTH +# define DRM_CAP_CURSOR_WIDTH 0x8 +#endif + +#ifndef DRM_CAP_CURSOR_HEIGHT +# define DRM_CAP_CURSOR_HEIGHT 0x9 +#endif + +namespace Aurora { + +namespace Platform { + +DrmCursor::DrmCursor(QObject *parent) + : QObject(parent) +{ + const auto fd = DrmBackend::instance()->primaryGpu()->fd(); + auto *gbmDevice = DrmBackend::instance()->primaryGpu()->gbmDevice(); + + uint64_t width, height; + if ((drmGetCap(fd, DRM_CAP_CURSOR_WIDTH, &width) == 0) + && (drmGetCap(fd, DRM_CAP_CURSOR_HEIGHT, &height) == 0)) { + m_cursorSize.setWidth(width); + m_cursorSize.setHeight(height); + } + + m_gbmBo = gbm_bo_create(gbmDevice, m_cursorSize.width(), m_cursorSize.height(), + GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE); + if (!m_gbmBo) + qCWarning(gLcDrm) << "Failed to create buffer for cursor"; +} + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmcursor.h b/src/plugins/deviceintegration/drm/drmcursor.h new file mode 100644 index 00000000..b2ab057e --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmcursor.h @@ -0,0 +1,27 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include +#include + +struct gbm_bo; + +namespace Aurora { + +namespace Platform { + +class DrmCursor : public QObject +{ +public: + explicit DrmCursor(QObject *parent = nullptr); + +private: + QSize m_cursorSize = QSize(64, 64); + gbm_bo *m_gbmBo; +}; + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmgpu.cpp b/src/plugins/deviceintegration/drm/drmgpu.cpp new file mode 100644 index 00000000..ad1425dd --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmgpu.cpp @@ -0,0 +1,73 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "drmbackend.h" +#include "drmgpu.h" + +#include + +namespace Aurora { + +namespace Platform { + +DrmGpu::DrmGpu(const QString &path, int fd, dev_t deviceId, QObject *parent) + : QObject(parent) + , m_deviceNode(path) + , m_fd(fd) + , m_deviceId(deviceId) +{ + m_gbmDevice = gbm_create_device(fd); + if (!m_gbmDevice) + qFatal("Unable to create GBM device for \"%s\"", qPrintable(path)); +} + +DrmGpu::~DrmGpu() +{ + if (m_gbmDevice) { + gbm_device_destroy(m_gbmDevice); + m_gbmDevice = nullptr; + } + + if (m_fd >= 0) { + DrmBackend::instance()->session()->closeRestricted(m_fd); + m_fd = -1; + } +} + +int DrmGpu::fd() const +{ + return m_fd; +} + +dev_t DrmGpu::deviceId() const +{ + return m_deviceId; +} + +QString DrmGpu::deviceNode() const +{ + return m_deviceNode; +} + +gbm_device *DrmGpu::gbmDevice() const +{ + return m_gbmDevice; +} + +bool DrmGpu::isActive() const +{ + return m_active; +} + +void DrmGpu::setActive(bool value) +{ + if (m_active == value) + return; + + m_active = value; + emit activeChanged(value); +} + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmgpu.h b/src/plugins/deviceintegration/drm/drmgpu.h new file mode 100644 index 00000000..212d1c54 --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmgpu.h @@ -0,0 +1,47 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include + +struct gbm_device; + +namespace Aurora { + +namespace Platform { + +class DrmOutput; + +class DrmGpu : public QObject +{ + Q_OBJECT +public: + explicit DrmGpu(const QString &path, int fd, dev_t deviceId, QObject *parent = nullptr); + ~DrmGpu(); + + int fd() const; + dev_t deviceId() const; + QString deviceNode() const; + + gbm_device *gbmDevice() const; + + bool isActive() const; + void setActive(bool value); + +signals: + void activeChanged(bool active); + void outputAdded(DrmOutput *output); + void outputRemoved(DrmOutput *output); + +private: + QString m_deviceNode; + int m_fd = -1; + dev_t m_deviceId = -1; + gbm_device *m_gbmDevice = nullptr; + bool m_active = true; +}; + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmintegration.cpp b/src/plugins/deviceintegration/drm/drmintegration.cpp new file mode 100644 index 00000000..8b7dc1db --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmintegration.cpp @@ -0,0 +1,104 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: GPL-3.0-or-later + +#include + +#include "drmbackend.h" +#include "drmintegration.h" +#include "drmgpu.h" +#include "drmloggingcategories.h" +#include "drmoutput.h" +#include "drmwindow.h" + +#include + +namespace Aurora { + +namespace Platform { + +DrmIntegration::DrmIntegration(QObject *parent) + : DeviceIntegration(parent) +{ +} + +DrmIntegration::~DrmIntegration() +{ +} + +void DrmIntegration::initialize() +{ + DrmBackend::instance()->initialize(); +} + +void DrmIntegration::destroy() +{ + qCDebug(gLcDrm, "DRM device integration is about to be destroyed..."); + + DrmBackend::instance()->destroy(); + + qCInfo(gLcDrm, "DRM device integration destroyed successfully"); +} + +EGLNativeDisplayType DrmIntegration::platformDisplay() const +{ + return DrmBackend::instance()->platformDisplay(); +} + +EGLDisplay DrmIntegration::eglDisplay() const +{ + return DrmBackend::instance()->eglDisplay(); +} + +EGLNativeWindowType DrmIntegration::createNativeWindow(Window *window, const QSize &size, + const QSurfaceFormat &format) +{ + Q_UNUSED(format) + + auto *drmOutput = static_cast(window->output()); + auto *gbmDevice = DrmBackend::instance()->primaryGpu()->gbmDevice(); + auto *gbmSurface = + gbm_surface_create(gbmDevice, size.width(), size.height(), drmOutput->format(), + GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); + + return reinterpret_cast(gbmSurface); +} + +void DrmIntegration::destroyNativeWindow(EGLNativeWindowType nativeWindow) +{ + auto *surface = reinterpret_cast(nativeWindow); + gbm_surface_destroy(surface); +} + +void DrmIntegration::waitForVSync(Window *window) const +{ + Q_UNUSED(window) +} + +void DrmIntegration::presentBuffer(Window *window) +{ + Q_UNUSED(window) +} + +Window *DrmIntegration::createWindow(Output *output, QWindow *qtWindow) +{ + return nullptr; +} + +Window *DrmIntegration::getWindow(QWindow *qtWindow) const +{ + return nullptr; +} + +InputManager *DrmIntegration::createInputManager() +{ + return nullptr; +} + +Outputs DrmIntegration::outputs() const +{ + return Outputs(); +} + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmintegration.h b/src/plugins/deviceintegration/drm/drmintegration.h new file mode 100644 index 00000000..839eb45a --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmintegration.h @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include + +namespace Aurora { + +namespace Platform { + +class DrmWindow; + +class DrmIntegration : public DeviceIntegration +{ + Q_OBJECT +public: + explicit DrmIntegration(QObject *parent = nullptr); + ~DrmIntegration(); + + void initialize() override; + void destroy() override; + + EGLNativeDisplayType platformDisplay() const override; + EGLDisplay eglDisplay() const override; + + EGLNativeWindowType createNativeWindow(Window *window, const QSize &size, + const QSurfaceFormat &format) override; + void destroyNativeWindow(EGLNativeWindowType nativeWindow) override; + + void waitForVSync(Window *window) const override; + void presentBuffer(Window *window) override; + + Window *createWindow(Output *output, QWindow *qtWindow) override; + Window *getWindow(QWindow *qtWindow) const override; + + InputManager *createInputManager() override; + + Outputs outputs() const override; +}; + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmintegrationplugin.cpp b/src/plugins/deviceintegration/drm/drmintegrationplugin.cpp new file mode 100644 index 00000000..8742cb97 --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmintegrationplugin.cpp @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: LGPL-3.0-or-later + +#include "drmintegration.h" +#include "drmintegrationplugin.h" + +namespace Aurora { + +namespace Platform { + +DrmIntegrationPlugin::DrmIntegrationPlugin(QObject *parent) + : DeviceIntegrationPlugin(parent) +{ +} + +DeviceIntegration *DrmIntegrationPlugin::create() +{ + return new DrmIntegration(this); +} + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmintegrationplugin.h b/src/plugins/deviceintegration/drm/drmintegrationplugin.h new file mode 100644 index 00000000..ec9d24bf --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmintegrationplugin.h @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: LGPL-3.0-or-later + +#pragma once + +#include + +namespace Aurora { + +namespace Platform { + +class DrmIntegrationPlugin : public DeviceIntegrationPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "io.liri.Aurora.DeviceIntegrationPlugin/1" FILE "drm.json") +public: + explicit DrmIntegrationPlugin(QObject *parent = nullptr); + + DeviceIntegration *create() override; +}; + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmoutput.cpp b/src/plugins/deviceintegration/drm/drmoutput.cpp new file mode 100644 index 00000000..ca8ef48f --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmoutput.cpp @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "drmoutput.h" + +namespace Aurora { + +namespace Platform { + +DrmOutput::DrmOutput(QObject *parent) + : Output(parent) +{ +} + +uint32_t DrmOutput::format() const +{ + return 0; +} + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmoutput.h b/src/plugins/deviceintegration/drm/drmoutput.h new file mode 100644 index 00000000..07f5d18f --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmoutput.h @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include + +namespace Aurora { + +namespace Platform { + +class DrmOutput : public Output +{ + Q_OBJECT +public: + explicit DrmOutput(QObject *parent = nullptr); + + uint32_t format() const; +}; + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmwindow.cpp b/src/plugins/deviceintegration/drm/drmwindow.cpp new file mode 100644 index 00000000..0a1c13e3 --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmwindow.cpp @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "drmcursor.h" +#include "drmwindow.h" + +namespace Aurora { + +namespace Platform { + +DrmWindow::DrmWindow(DrmOutput *output, QWindow *qtWindow, QObject *parent) + : Window(output, qtWindow, parent) + , m_cursor(new DrmCursor(this)) +{ +} + +} // namespace Platform + +} // namespace Aurora diff --git a/src/plugins/deviceintegration/drm/drmwindow.h b/src/plugins/deviceintegration/drm/drmwindow.h new file mode 100644 index 00000000..0e845d46 --- /dev/null +++ b/src/plugins/deviceintegration/drm/drmwindow.h @@ -0,0 +1,28 @@ +// SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include + +#include "drmoutput.h" + +namespace Aurora { + +namespace Platform { + +class DrmCursor; + +class DrmWindow : public Window +{ + Q_OBJECT +public: + explicit DrmWindow(DrmOutput *output, QWindow *qtWindow, QObject *parent = nullptr); + +private: + DrmCursor *m_cursor = nullptr; +}; + +} // namespace Platform + +} // namespace Aurora