This repository has been archived by the owner on Nov 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 340
DRM backend + Session interface + EGL #2
Merged
Merged
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
aca1332
Inital commit of libotd.
ascent12 95a553d
Moved headers to the correct place.
ascent12 9ac46ec
Got it to build
ascent12 41a82fd
Renaming.
ascent12 562d43a
Changed logging.
ascent12 115d4ae
Changed events to use wayland functions.
ascent12 e9d716f
Changed display to use list_t.
ascent12 e446a53
Added example.
ascent12 762ac7f
New session interface.
ascent12 81998fd
Removed old session code from DRM backend.
ascent12 dbceaee
Added EGL interface for backends.
ascent12 15d247b
Changed drm to use new EGL interface.
ascent12 1838746
Renamed 'wlr_drm_display' to 'wlr_drm_output'
ascent12 0002b8d
Added 'direct' session backend
ascent12 d196a79
Changed backend to accept wl_display.
ascent12 ef97688
Changed modesetting interface.
ascent12 4285b0c
Removed unused fields.
ascent12 7e9feb7
Fixed hotplugging + make EGL more chatty.
ascent12 15b1ce9
Refactor backend state management
ddevault 00931f2
Generalize output handling
ddevault 42878b4
Remove unnecessary TODO
ddevault File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#.rst: | ||
# FindGBM | ||
# ------- | ||
# | ||
# Find GBM library | ||
# | ||
# Try to find GBM library on UNIX systems. The following values are defined | ||
# | ||
# :: | ||
# | ||
# GBM_FOUND - True if gbm is available | ||
# GBM_INCLUDE_DIRS - Include directories for gbm | ||
# GBM_LIBRARIES - List of libraries for gbm | ||
# GBM_DEFINITIONS - List of definitions for gbm | ||
# | ||
#============================================================================= | ||
# Copyright (c) 2015 Jari Vetoniemi | ||
# | ||
# Distributed under the OSI-approved BSD License (the "License"); | ||
# | ||
# This software is distributed WITHOUT ANY WARRANTY; without even the | ||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the License for more information. | ||
#============================================================================= | ||
|
||
set_package_properties(GBM PROPERTIES | ||
URL "http://www.mesa3d.org/" | ||
DESCRIPTION "Generic buffer manager") | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(PC_GBM QUIET gbm) | ||
find_library(GBM_LIBRARIES NAMES gbm HINTS ${PC_GBM_LIBRARY_DIRS}) | ||
find_path(GBM_INCLUDE_DIRS gbm.h HINTS ${PC_GBM_INCLUDE_DIRS}) | ||
|
||
set(GBM_DEFINITIONS ${PC_GBM_CFLAGS_OTHER}) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(GBM DEFAULT_MSG GBM_INCLUDE_DIRS GBM_LIBRARIES) | ||
mark_as_advanced(GBM_INCLUDE_DIRS GBM_LIBRARIES GBM_DEFINITIONS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#.rst: | ||
# FindSystemd | ||
# ------- | ||
# | ||
# Find Systemd library | ||
# | ||
# Try to find Systemd library on UNIX systems. The following values are defined | ||
# | ||
# :: | ||
# | ||
# SYSTEMD_FOUND - True if Systemd is available | ||
# SYSTEMD_INCLUDE_DIRS - Include directories for Systemd | ||
# SYSTEMD_LIBRARIES - List of libraries for Systemd | ||
# SYSTEMD_DEFINITIONS - List of definitions for Systemd | ||
# | ||
#============================================================================= | ||
# Copyright (c) 2015 Jari Vetoniemi | ||
# | ||
# Distributed under the OSI-approved BSD License (the "License"); | ||
# | ||
# This software is distributed WITHOUT ANY WARRANTY; without even the | ||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the License for more information. | ||
#============================================================================= | ||
|
||
include(FeatureSummary) | ||
set_package_properties(Systemd PROPERTIES | ||
URL "http://freedesktop.org/wiki/Software/systemd/" | ||
DESCRIPTION "System and Service Manager") | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(PC_SYSTEMD QUIET libsystemd) | ||
find_library(SYSTEMD_LIBRARIES NAMES systemd ${PC_SYSTEMD_LIBRARY_DIRS}) | ||
find_path(SYSTEMD_INCLUDE_DIRS systemd/sd-login.h HINTS ${PC_SYSTEMD_INCLUDE_DIRS}) | ||
|
||
set(SYSTEMD_DEFINITIONS ${PC_SYSTEMD_CFLAGS_OTHER}) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(SYSTEMD DEFAULT_MSG SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES) | ||
mark_as_advanced(SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES SYSTEMD_DEFINITIONS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,29 @@ | ||
include_directories( | ||
${PROTOCOLS_INCLUDE_DIRS} | ||
${WAYLAND_INCLUDE_DIR} | ||
${DRM_INCLUDE_DIRS} | ||
) | ||
|
||
add_library(wlr-backend | ||
wayland/backend.c | ||
wayland/registry.c | ||
wayland/wl_seat.c | ||
wayland/wl_output.c | ||
drm/backend.c | ||
drm/drm.c | ||
drm/session.c | ||
drm/udev.c | ||
) | ||
|
||
target_link_libraries(wlr-backend | ||
wlr-common | ||
wlr-wayland | ||
${WAYLAND_LIBRARIES} | ||
${DRM_LIBRARIES} | ||
${GBM_LIBRARIES} | ||
${GLESv2_LIBRARIES} | ||
${EGL_LIBRARIES} | ||
${SYSTEMD_LIBRARIES} | ||
${UDEV_LIBRARIES} | ||
${GBM_LIBRARIES} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <errno.h> | ||
|
||
#include <wlr/common/list.h> | ||
|
||
#include "backend/drm/backend.h" | ||
#include "backend/drm/drm.h" | ||
#include "backend/drm/session.h" | ||
#include "backend/drm/udev.h" | ||
#include "common/log.h" | ||
|
||
struct wlr_drm_backend *wlr_drm_backend_init(struct wl_listener *add, | ||
struct wl_listener *rem, | ||
struct wl_listener *render) | ||
{ | ||
struct wlr_drm_backend *backend = calloc(1, sizeof *backend); | ||
if (!backend) { | ||
wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno)); | ||
return NULL; | ||
} | ||
|
||
backend->displays = list_create(); | ||
if (!backend->displays) { | ||
wlr_log(L_ERROR, "Failed to allocate list"); | ||
goto error_backend; | ||
} | ||
|
||
backend->event_loop = wl_event_loop_create(); | ||
if (!backend->event_loop) { | ||
wlr_log(L_ERROR, "Failed to create event loop"); | ||
goto error_list; | ||
} | ||
|
||
if (!wlr_session_start(&backend->session)) { | ||
wlr_log(L_ERROR, "Failed to start session"); | ||
goto error_loop; | ||
} | ||
|
||
if (!wlr_udev_init(backend)) { | ||
wlr_log(L_ERROR, "Failed to start udev"); | ||
goto error_session; | ||
} | ||
|
||
backend->fd = wlr_udev_find_gpu(&backend->udev, &backend->session); | ||
if (backend->fd == -1) { | ||
wlr_log(L_ERROR, "Failed to open DRM device"); | ||
goto error_udev; | ||
} | ||
|
||
if (!wlr_drm_renderer_init(&backend->renderer, backend, backend->fd)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At some point I would like to detach this somewhat from the backend as well, but for now it's fine. |
||
wlr_log(L_ERROR, "Failed to initialize renderer"); | ||
goto error_fd; | ||
} | ||
|
||
wl_signal_init(&backend->signals.display_add); | ||
wl_signal_init(&backend->signals.display_rem); | ||
wl_signal_init(&backend->signals.display_render); | ||
|
||
if (add) | ||
wl_signal_add(&backend->signals.display_add, add); | ||
if (rem) | ||
wl_signal_add(&backend->signals.display_rem, rem); | ||
if (render) | ||
wl_signal_add(&backend->signals.display_render, render); | ||
|
||
wlr_drm_scan_connectors(backend); | ||
|
||
return backend; | ||
|
||
error_fd: | ||
wlr_session_release_device(&backend->session, backend->fd); | ||
error_udev: | ||
wlr_udev_free(&backend->udev); | ||
error_session: | ||
wlr_session_end(&backend->session); | ||
error_loop: | ||
wl_event_loop_destroy(backend->event_loop); | ||
error_list: | ||
list_free(backend->displays); | ||
error_backend: | ||
free(backend); | ||
return NULL; | ||
} | ||
|
||
static void free_display(void *item) | ||
{ | ||
struct wlr_drm_display *disp = item; | ||
wlr_drm_display_free(disp, true); | ||
free(disp); | ||
} | ||
|
||
void wlr_drm_backend_free(struct wlr_drm_backend *backend) | ||
{ | ||
if (!backend) | ||
return; | ||
|
||
list_foreach(backend->displays, free_display); | ||
|
||
wlr_drm_renderer_free(&backend->renderer); | ||
wlr_udev_free(&backend->udev); | ||
wlr_session_release_device(&backend->session, backend->fd); | ||
wlr_session_end(&backend->session); | ||
|
||
wl_event_source_remove(backend->event_src.drm); | ||
wl_event_source_remove(backend->event_src.udev); | ||
wl_event_loop_destroy(backend->event_loop); | ||
|
||
list_free(backend->displays); | ||
free(backend); | ||
} | ||
|
||
struct wl_event_loop *wlr_drm_backend_get_event_loop(struct wlr_drm_backend *backend) | ||
{ | ||
return backend->event_loop; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be easy to make optional with the approach I described.