diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/backend.c | 10 | ||||
-rw-r--r-- | backend/drm/backend.c | 8 | ||||
-rw-r--r-- | backend/drm/drm.c | 43 |
3 files changed, 33 insertions, 28 deletions
diff --git a/backend/backend.c b/backend/backend.c index 753bb3ae..c6afe9ed 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -2,7 +2,9 @@ #include <stdlib.h> #include <string.h> #include <errno.h> +#include <wlr/session.h> #include "common/log.h" +#include "backend/drm/backend.h" #include "backend.h" struct wlr_backend *wlr_backend_create(const struct wlr_backend_impl *impl, @@ -34,3 +36,11 @@ void wlr_backend_destroy(struct wlr_backend *backend) { // TODO: free outputs free(backend); } + +struct wlr_backend *wlr_backend_autocreate(struct wl_display *display, + struct wlr_session *session) { + // TODO: Choose the most appropriate backend for the situation + struct wlr_backend *wlr; + wlr = wlr_drm_backend_create(display, session); + return wlr; +} diff --git a/backend/drm/backend.c b/backend/drm/backend.c index f202d4d6..0da84745 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -101,11 +101,3 @@ error_backend: free(backend); return NULL; } - -void wlr_drm_backend_dpms(struct wlr_backend *backend, bool screen_on) { - struct wlr_backend_state *state = backend->state; - for (size_t i = 0; i < state->outputs->length; ++i) { - struct wlr_output_state *output = state->outputs->items[i]; - wlr_drm_output_dpms(state->fd, output, screen_on); - } -} diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 8ec27b80..e9af9899 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -236,6 +236,28 @@ error: return false; } +static void wlr_drm_output_enable(struct wlr_output_state *output, bool enable) { + struct wlr_backend_state *state = + wl_container_of(output->renderer, state, renderer); + if (output->state != DRM_OUTPUT_CONNECTED) { + return; + } + + if (enable) { + drmModeConnectorSetProperty(state->fd, output->connector, output->props.dpms, + DRM_MODE_DPMS_ON); + + // Start rendering loop again by drawing a black frame + wlr_drm_output_begin(output); + glClearColor(0.0, 0.0, 0.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + wlr_drm_output_end(output); + } else { + drmModeConnectorSetProperty(state->fd, output->connector, output->props.dpms, + DRM_MODE_DPMS_STANDBY); + } +} + static void wlr_drm_output_destroy(struct wlr_output_state *output) { wlr_drm_output_cleanup(output, true); wlr_drm_renderer_free(output->renderer); @@ -244,6 +266,7 @@ static void wlr_drm_output_destroy(struct wlr_output_state *output) { static struct wlr_output_impl output_impl = { .set_mode = wlr_drm_output_set_mode, + .enable = wlr_drm_output_enable, .destroy = wlr_drm_output_destroy, }; @@ -454,23 +477,3 @@ void wlr_drm_output_cleanup(struct wlr_output_state *output, bool restore) { } // TODO: free wlr_output } - -void wlr_drm_output_dpms(int fd, struct wlr_output_state *output, bool screen_on) { - if (output->state != DRM_OUTPUT_CONNECTED) { - return; - } - - if (screen_on) { - drmModeConnectorSetProperty(fd, output->connector, output->props.dpms, - DRM_MODE_DPMS_ON); - - // Start rendering loop again by drawing a black frame - wlr_drm_output_begin(output); - glClearColor(0.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - wlr_drm_output_end(output); - } else { - drmModeConnectorSetProperty(fd, output->connector, output->props.dpms, - DRM_MODE_DPMS_STANDBY); - } -} |