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 343
DRM backend + Session interface + EGL #2
Merged
Merged
Changes from all 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,30 @@ | ||
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 | ||
#wayland/backend.c | ||
#wayland/registry.c | ||
#wayland/wl_seat.c | ||
#wayland/wl_output.c | ||
drm/backend.c | ||
drm/drm.c | ||
drm/udev.c | ||
backend.c | ||
egl.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,36 @@ | ||
#include <wayland-server.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <errno.h> | ||
#include "common/log.h" | ||
#include "backend.h" | ||
|
||
struct wlr_backend *wlr_backend_create(const struct wlr_backend_impl *impl, | ||
struct wlr_backend_state *state) { | ||
struct wlr_backend *backend = calloc(1, sizeof(struct wlr_backend)); | ||
if (!backend) { | ||
wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno)); | ||
return NULL; | ||
} | ||
backend->state = state; | ||
backend->impl = impl; | ||
wl_signal_init(&backend->events.output_add); | ||
wl_signal_init(&backend->events.output_remove); | ||
wl_signal_init(&backend->events.keyboard_add); | ||
wl_signal_init(&backend->events.keyboard_remove); | ||
wl_signal_init(&backend->events.pointer_add); | ||
wl_signal_init(&backend->events.pointer_remove); | ||
wl_signal_init(&backend->events.touch_add); | ||
wl_signal_init(&backend->events.touch_remove); | ||
return backend; | ||
} | ||
|
||
bool wlr_backend_init(struct wlr_backend *backend) { | ||
return backend->impl->init(backend->state); | ||
} | ||
|
||
void wlr_backend_destroy(struct wlr_backend *backend) { | ||
backend->impl->destroy(backend->state); | ||
// TODO: free outputs | ||
free(backend); | ||
} |
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,103 @@ | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <errno.h> | ||
#include <wayland-server.h> | ||
|
||
#include <wlr/session.h> | ||
#include <wlr/common/list.h> | ||
|
||
#include "backend.h" | ||
#include "backend/drm/backend.h" | ||
#include "backend/drm/drm.h" | ||
#include "backend/drm/udev.h" | ||
#include "common/log.h" | ||
|
||
static bool wlr_drm_backend_init(struct wlr_backend_state *state) { | ||
wlr_drm_scan_connectors(state); | ||
return true; | ||
} | ||
|
||
static void wlr_drm_backend_destroy(struct wlr_backend_state *state) { | ||
if (!state) { | ||
return; | ||
} | ||
// TODO: free outputs in shared backend code | ||
wlr_drm_renderer_free(&state->renderer); | ||
wlr_udev_free(&state->udev); | ||
wlr_session_close_file(state->session, state->fd); | ||
wlr_session_finish(state->session); | ||
wl_event_source_remove(state->drm_event); | ||
free(state); | ||
} | ||
|
||
static struct wlr_backend_impl backend_impl = { | ||
.init = wlr_drm_backend_init, | ||
.destroy = wlr_drm_backend_destroy | ||
}; | ||
|
||
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, | ||
struct wlr_session *session) { | ||
struct wlr_backend_state *state = calloc(1, sizeof(struct wlr_backend_state)); | ||
if (!state) { | ||
wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno)); | ||
return NULL; | ||
} | ||
|
||
struct wlr_backend *backend = wlr_backend_create(&backend_impl, state); | ||
if (!backend) { | ||
wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno)); | ||
return NULL; | ||
} | ||
|
||
state->backend = backend; | ||
state->session = session; | ||
state->outputs = list_create(); | ||
if (!state->outputs) { | ||
wlr_log(L_ERROR, "Failed to allocate list"); | ||
goto error_backend; | ||
} | ||
|
||
if (!wlr_udev_init(display, &state->udev)) { | ||
wlr_log(L_ERROR, "Failed to start udev"); | ||
goto error_list; | ||
} | ||
|
||
state->fd = wlr_udev_find_gpu(&state->udev, state->session); | ||
if (state->fd == -1) { | ||
wlr_log(L_ERROR, "Failed to open DRM device"); | ||
goto error_udev; | ||
} | ||
|
||
struct wl_event_loop *event_loop = wl_display_get_event_loop(display); | ||
|
||
state->drm_event = wl_event_loop_add_fd(event_loop, state->fd, | ||
WL_EVENT_READABLE, wlr_drm_event, NULL); | ||
if (!state->drm_event) { | ||
wlr_log(L_ERROR, "Failed to create DRM event source"); | ||
goto error_fd; | ||
} | ||
|
||
// TODO: what is the difference between the per-output renderer and this | ||
// one? | ||
if (!wlr_drm_renderer_init(&state->renderer, state->fd)) { | ||
wlr_log(L_ERROR, "Failed to initialize renderer"); | ||
goto error_event; | ||
} | ||
|
||
return backend; | ||
|
||
error_event: | ||
wl_event_source_remove(state->drm_event); | ||
error_fd: | ||
wlr_session_close_file(state->session, state->fd); | ||
error_udev: | ||
wlr_udev_free(&state->udev); | ||
error_list: | ||
list_free(state->outputs); | ||
error_backend: | ||
free(state); | ||
free(backend); | ||
return NULL; | ||
} |
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.
Note
wlr_backend_autocreate
will eventually be made to automatically create the most appropriate backend. It will handle udev and logind and things like that, and will invoke the most appropriate backend'swlr_*_backend_create
function. This function,wlr_backend_create
, is an internal function used by the backends to create the user-facing backend object.