From 771263380c3b3b4b412964b0fe53619aa7c580e2 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 4 Jan 2018 12:46:15 +0100 Subject: Add wlr_output::enabled --- backend/drm/drm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'backend/drm/drm.c') diff --git a/backend/drm/drm.c b/backend/drm/drm.c index dd5c97f5..32b2f88c 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -257,6 +257,8 @@ static void wlr_drm_connector_enable(struct wlr_output *output, bool enable) { if (enable) { wlr_drm_connector_start_renderer(conn); } + + wlr_output_update_enabled(&conn->output, enable); } static void realloc_planes(struct wlr_drm_backend *drm, const uint32_t *crtc_in, @@ -722,7 +724,8 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) { drmModeFreeConnector(drm_conn); continue; } - wlr_output_init(&wlr_conn->output, &drm->backend, &output_impl); + wlr_output_init(&wlr_conn->output, &drm->backend, &output_impl, + drm->display); struct wl_event_loop *ev = wl_display_get_event_loop(drm->display); wlr_conn->retry_pageflip = wl_event_loop_add_timer(ev, retry_pageflip, @@ -792,7 +795,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) { wl_list_insert(&wlr_conn->output.modes, &mode->wlr_mode.link); } - wlr_output_create_global(&wlr_conn->output, drm->display); + wlr_output_update_enabled(&wlr_conn->output, true); wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET; wlr_log(L_INFO, "Sending modesetting signal for '%s'", @@ -802,7 +805,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) { drm_conn->connection != DRM_MODE_CONNECTED) { wlr_log(L_INFO, "'%s' disconnected", wlr_conn->output.name); - wlr_output_destroy_global(&wlr_conn->output); + wlr_output_update_enabled(&wlr_conn->output, false); wlr_drm_connector_cleanup(wlr_conn); } -- cgit v1.2.3 From 53ba9b4eec4345cb5ba6640e8677f3b2477d2693 Mon Sep 17 00:00:00 2001 From: emersion Date: Sun, 7 Jan 2018 00:28:21 +0100 Subject: Fix output enable in DRM backend --- backend/drm/atomic.c | 14 +++++++++++--- backend/drm/drm.c | 5 ++++- backend/drm/legacy.c | 5 +++-- include/backend/drm/iface.h | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) (limited to 'backend/drm/drm.c') diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index e7374a00..8d98bac2 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -123,14 +123,22 @@ static bool atomic_crtc_pageflip(struct wlr_drm_backend *drm, mode); } -static void atomic_conn_enable(struct wlr_drm_backend *drm, +static bool atomic_conn_enable(struct wlr_drm_backend *drm, struct wlr_drm_connector *conn, bool enable) { struct wlr_drm_crtc *crtc = conn->crtc; - struct atomic atom; + struct atomic atom; atomic_begin(crtc, &atom); atomic_add(&atom, crtc->id, crtc->props.active, enable); - atomic_end(drm->fd, &atom); + if (enable) { + atomic_add(&atom, conn->id, conn->props.crtc_id, crtc->id); + atomic_add(&atom, crtc->id, crtc->props.mode_id, crtc->mode_id); + } else { + atomic_add(&atom, conn->id, conn->props.crtc_id, 0); + atomic_add(&atom, crtc->id, crtc->props.mode_id, 0); + } + return atomic_commit(drm->fd, &atom, conn, DRM_MODE_ATOMIC_ALLOW_MODESET, + true); } bool legacy_crtc_set_cursor(struct wlr_drm_backend *drm, diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 32b2f88c..0d32605a 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -252,7 +252,10 @@ static void wlr_drm_connector_enable(struct wlr_output *output, bool enable) { } struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend; - drm->iface->conn_enable(drm, conn, enable); + bool ok = drm->iface->conn_enable(drm, conn, enable); + if (!ok) { + return; + } if (enable) { wlr_drm_connector_start_renderer(conn); diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c index d75eb2cb..61140cec 100644 --- a/backend/drm/legacy.c +++ b/backend/drm/legacy.c @@ -25,10 +25,11 @@ static bool legacy_crtc_pageflip(struct wlr_drm_backend *drm, return true; } -static void legacy_conn_enable(struct wlr_drm_backend *drm, +static bool legacy_conn_enable(struct wlr_drm_backend *drm, struct wlr_drm_connector *conn, bool enable) { - drmModeConnectorSetProperty(drm->fd, conn->id, conn->props.dpms, + int ret = drmModeConnectorSetProperty(drm->fd, conn->id, conn->props.dpms, enable ? DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF); + return ret >= 0; } bool legacy_crtc_set_cursor(struct wlr_drm_backend *drm, diff --git a/include/backend/drm/iface.h b/include/backend/drm/iface.h index bc61eb51..4a5d2e9d 100644 --- a/include/backend/drm/iface.h +++ b/include/backend/drm/iface.h @@ -15,7 +15,7 @@ struct wlr_drm_crtc; // Used to provide atomic or legacy DRM functions struct wlr_drm_interface { // Enable or disable DPMS for connector - void (*conn_enable)(struct wlr_drm_backend *drm, + bool (*conn_enable)(struct wlr_drm_backend *drm, struct wlr_drm_connector *conn, bool enable); // Pageflip on crtc. If mode is non-NULL perform a full modeset using it. bool (*crtc_pageflip)(struct wlr_drm_backend *drm, -- cgit v1.2.3