Skip to content

Commit

Permalink
Device integration for DRM/KMS
Browse files Browse the repository at this point in the history
Closes: #43
  • Loading branch information
plfiorini committed Jan 25, 2024
1 parent 05d250e commit 4acb756
Show file tree
Hide file tree
Showing 66 changed files with 9,803 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ if(FEATURE_aurora_qpa)
add_subdirectory(src/plugins/platforms/eglfs)
# add_subdirectory(src/platformsupport/libinput)
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()
Expand Down
7 changes: 7 additions & 0 deletions cmake/FindLibDisplayInfo.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2024 Pier Luigi Fiorini <[email protected]>
# SPDX-License-Identifier: BSD-3-Clause

if(NOT TARGET PkgConfig::LibDisplayInfo)
find_package(PkgConfig QUIET)
pkg_check_modules(LibDisplayInfo libdisplay-info IMPORTED_TARGET)
endif()
7 changes: 7 additions & 0 deletions cmake/FindLibxcvt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2024 Pier Luigi Fiorini <[email protected]>
# SPDX-License-Identifier: BSD-3-Clause

if(NOT TARGET PkgConfig::Libxcvt)
find_package(PkgConfig QUIET)
pkg_check_modules(Libxcvt libxcvt IMPORTED_TARGET)
endif()
39 changes: 39 additions & 0 deletions features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ if(FEATURE_aurora_qpa)
find_package(Libinput QUIET)
find_package(Libdrm QUIET)
find_package(Gbm QUIET)
find_package(Libxcvt QUIET)
find_package(LibDisplayInfo QUIET)

if(NOT TARGET EGL::EGL)
message(WARNING "You need EGL for Aurora::QPA")
Expand All @@ -328,6 +330,14 @@ if(FEATURE_aurora_qpa)
message(WARNING "You need libdrm for Aurora::QPA")
set(FEATURE_aurora_qpa OFF)
endif()
if(NOT TARGET PkgConfig::Libxcvt)
message(WARNING "You need libxcvt for Aurora::QPA")
set(FEATURE_aurora_qpa OFF)
endif()
if(NOT TARGET PkgConfig::LibDisplayInfo)
message(WARNING "You need libdisplay-info for Aurora::QPA")
set(FEATURE_aurora_qpa OFF)
endif()
if(NOT TARGET PkgConfig::Gbm)
message(WARNING "You need gbm for Aurora::QPA")
set(FEATURE_aurora_qpa OFF)
Expand Down Expand Up @@ -391,6 +401,35 @@ endif()
add_feature_info("Aurora::VulkanServerBuffer" FEATURE_aurora_vulkan_server_buffer "Build Wayland compositor with Vulkan-based server buffer integration")
set(LIRI_FEATURE_aurora_vulkan_server_buffer "$<IF:${FEATURE_aurora_vulkan_server_buffer},1,0>")

# 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 "$<IF:${FEATURE_aurora_deviceintegration_drm},1,0>")

# Device Integration: wayland
option(FEATURE_aurora_deviceintegration_wayland "Device Integration: wayland" ON)
if(FEATURE_aurora_deviceintegration_wayland)
Expand Down
62 changes: 62 additions & 0 deletions src/plugins/deviceintegration/drm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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"
)

qt6_add_plugin(AuroraDeviceIntegrationDrm
SHARED
CLASS_NAME DrmIntegrationPlugin
MANUAL_FINALIZATION
drmabstractoutput.cpp drmabstractoutput.h
drmbackend.cpp drmbackend.h
drmblob.cpp drmblob.h
drmbuffer.cpp drmbuffer.h
drmcommit.cpp drmcommit.h
drmcommitthread.cpp drmcommitthread.h
drmconnector.cpp drmconnector.h
drmcrtc.cpp drmcrtc.h
drmgpu.cpp drmgpu.h
drmintegration.cpp drmintegration.h
drmintegrationplugin.cpp drmintegrationplugin.h
drmlayer.cpp drmlayer.h
drmobject.cpp drmobject.h
drmoutput.cpp drmoutput.h
drmpipeline.cpp drmpipeline.h drmpipelinelegacy.cpp
drmplane.cpp drmplane.h
drmpointer.h
drmproperty.cpp drmproperty.h
drmrenderbackend.h
filedescriptor.cpp filedescriptor.h
${AuroraDeviceIntegrationDrm_SOURCES}
)

set_target_properties(AuroraDeviceIntegrationDrm
PROPERTIES OUTPUT_NAME drm
)

target_link_libraries(AuroraDeviceIntegrationDrm
PUBLIC
Qt6::Core
Qt6::Gui
Liri::AuroraCore
Liri::AuroraPlatform
EGL::EGL
PRIVATE
PkgConfig::Libdrm
PkgConfig::Gbm
PkgConfig::Libxcvt
PkgConfig::LibDisplayInfo
Liri::AuroraPlatformPrivate
)

qt6_finalize_target(AuroraDeviceIntegrationDrm)

install(
TARGETS AuroraDeviceIntegrationDrm
DESTINATION ${KDE_INSTALL_PLUGINDIR}/aurora/deviceintegration
)
3 changes: 3 additions & 0 deletions src/plugins/deviceintegration/drm/drm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Keys": [ "drm" ]
}
55 changes: 55 additions & 0 deletions src/plugins/deviceintegration/drm/drmabstractoutput.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-FileCopyrightText: 2024 Pier Luigi Fiorini <[email protected]>
// SPDX-FileCopyrightText: 2021 Xaver Hugl <[email protected]>
// SPDX-License-Identifier: GPL-2.0-or-later

#include "drmabstractoutput.h"
#include "core/renderbackend.h"
#include "drmbackend.h"
#include "drmgpu.h"
#include "drmlayer.h"

namespace Aurora {

namespace Platform {

DrmAbstractOutput::DrmAbstractOutput(DrmGpu *gpu)
: Output(gpu->platform())
, m_renderLoop(std::make_unique<RenderLoop>())
, m_gpu(gpu)
{
}

RenderLoop *DrmAbstractOutput::renderLoop() const
{
return m_renderLoop.get();
}

void DrmAbstractOutput::frameFailed() const
{
m_frame->failed();
}

void DrmAbstractOutput::pageFlipped(std::chrono::nanoseconds timestamp, PresentationMode mode)
{
const auto gpuTime =
primaryLayer() ? primaryLayer()->queryRenderTime() : std::chrono::nanoseconds::zero();
m_frame->presented(std::chrono::nanoseconds(1'000'000'000'000 / refreshRate()), timestamp,
gpuTime, mode);
m_frame.reset();
}

DrmGpu *DrmAbstractOutput::gpu() const
{
return m_gpu;
}

void DrmAbstractOutput::updateEnabled(bool enabled)
{
State next = m_state;
next.enabled = enabled;
setState(next);
}

} // namespace Platform

} // namespace Aurora
45 changes: 45 additions & 0 deletions src/plugins/deviceintegration/drm/drmabstractoutput.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-FileCopyrightText: 2024 Pier Luigi Fiorini <[email protected]>
// SPDX-FileCopyrightText: 2021 Xaver Hugl <[email protected]>
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <LiriAuroraPlatform/Output>

namespace Aurora {

namespace Platform {

class DrmBackend;
class DrmGpu;
class DrmOutputLayer;
class OutputFrame;

class DrmAbstractOutput : public Output
{
Q_OBJECT
public:
DrmAbstractOutput(DrmGpu *gpu);

RenderLoop *renderLoop() const override;
void frameFailed() const;
void pageFlipped(std::chrono::nanoseconds timestamp, PresentationMode mode);
DrmGpu *gpu() const;

virtual bool present(const std::shared_ptr<OutputFrame> &frame) = 0;
virtual DrmOutputLayer *primaryLayer() const = 0;
virtual DrmOutputLayer *cursorLayer() const = 0;

void updateEnabled(bool enabled);

protected:
friend class DrmGpu;

std::unique_ptr<RenderLoop> m_renderLoop;
std::shared_ptr<OutputFrame> m_frame;
DrmGpu *const m_gpu;
};

} // namespace Platform

} // namespace Aurora
Loading

0 comments on commit 4acb756

Please sign in to comment.