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 Feb 12, 2024
1 parent facff1f commit fe0539c
Show file tree
Hide file tree
Showing 41 changed files with 4,806 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()
37 changes: 37 additions & 0 deletions features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,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 @@ -398,6 +406,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
61 changes: 61 additions & 0 deletions src/plugins/deviceintegration/drm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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
c_ptr.h
drmbackend.cpp drmbackend.h
drmblob.cpp drmblob.h
drmcrtc.cpp drmcrtc.h
drmconnector.cpp drmconnector.h
drmdevice.cpp drmdevice.h
drmeventreader.cpp drmeventreader.h
drmintegration.cpp drmintegration.h
drmintegrationplugin.cpp drmintegrationplugin.h
drmobject.cpp drmobject.h
drmoutput.cpp drmoutput.h
drmplane.cpp drmplane.h
drmpointer.h
drmproperty.cpp drmproperty.h
drmwindow.cpp drmwindow.h
edid.cpp edid.h
filedescriptor.cpp filedescriptor.h
udev.cpp udev.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
PkgConfig::Libudev
Liri::AuroraPlatformPrivate
)

qt6_finalize_target(AuroraDeviceIntegrationDrm)

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

#pragma once

#include <memory>

namespace Aurora {

namespace Platform {

struct CDeleter
{
template<typename T>
void operator()(T *ptr)
{
if (ptr) {
free(ptr);
}
}
};

template<typename T>
using UniqueCPtr = std::unique_ptr<T, CDeleter>;

} // namespace Platform

} // namespace Aurora
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" ]
}
Loading

0 comments on commit fe0539c

Please sign in to comment.