From fee409bd0af6f2e77116e7d8eddf99dd5225b1dc Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 31 May 2017 15:38:26 -0400 Subject: Generalize DPMS, remove DRM refs from example --- backend/drm/backend.c | 8 -------- backend/drm/drm.c | 43 +++++++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 28 deletions(-) (limited to 'backend/drm') 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); - } -} -- cgit v1.2.3