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 --- include/wlr/interfaces/wlr_output.h | 7 ++----- include/wlr/types/wlr_output.h | 10 ++++++---- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h index 6d71f9b6..d5837def 100644 --- a/include/wlr/interfaces/wlr_output.h +++ b/include/wlr/interfaces/wlr_output.h @@ -26,14 +26,11 @@ struct wlr_output_impl { }; void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, - const struct wlr_output_impl *impl); -void wlr_output_free(struct wlr_output *output); + const struct wlr_output_impl *impl, struct wl_display *display); void wlr_output_update_mode(struct wlr_output *output, struct wlr_output_mode *mode); void wlr_output_update_custom_mode(struct wlr_output *output, int32_t width, int32_t height, int32_t refresh); -struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output, - struct wl_display *display); -void wlr_output_destroy_global(struct wlr_output *wlr_output); +void wlr_output_update_enabled(struct wlr_output *output, bool enabled); #endif diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 6374ae9b..e7491704 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -36,19 +36,19 @@ struct wlr_output_impl; struct wlr_output { const struct wlr_output_impl *impl; struct wlr_backend *backend; + struct wl_display *display; struct wl_global *wl_global; struct wl_list wl_resources; - uint32_t flags; char name[16]; char make[48]; char model[16]; char serial[16]; - float scale; - int32_t width, height; - int32_t refresh; // mHz int32_t phys_width, phys_height; // mm + + bool enabled; + float scale; enum wl_output_subpixel subpixel; enum wl_output_transform transform; bool needs_swap; @@ -58,6 +58,8 @@ struct wlr_output { // Note: some backends may have zero modes struct wl_list modes; struct wlr_output_mode *current_mode; + int32_t width, height; + int32_t refresh; // mHz struct { struct wl_signal frame; -- cgit v1.2.3 From d9ecfbaf325f66b15d60d0f8c4fe08a939cb6576 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 4 Jan 2018 14:51:36 +0100 Subject: Add wlr_output enable event --- include/wlr/types/wlr_output.h | 1 + types/wlr_output.c | 3 +++ 2 files changed, 4 insertions(+) (limited to 'include') diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index e7491704..a726c4c8 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -64,6 +64,7 @@ struct wlr_output { struct { struct wl_signal frame; struct wl_signal swap_buffers; + struct wl_signal enable; struct wl_signal resolution; struct wl_signal scale; struct wl_signal transform; diff --git a/types/wlr_output.c b/types/wlr_output.c index 18c2ef89..4b842571 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -146,6 +146,8 @@ void wlr_output_update_enabled(struct wlr_output *output, bool enabled) { } else { wlr_output_destroy_global(output); } + + wl_signal_emit(&output->events.enable, output); } static void wlr_output_update_matrix(struct wlr_output *output) { @@ -269,6 +271,7 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, wl_signal_init(&output->events.frame); wl_signal_init(&output->events.swap_buffers); wl_signal_init(&output->events.resolution); + wl_signal_init(&output->events.enable); wl_signal_init(&output->events.scale); wl_signal_init(&output->events.transform); wl_signal_init(&output->events.destroy); -- cgit v1.2.3 From be3a7b0017823d80cd50c830d788a96e0e0ef6e8 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 4 Jan 2018 15:48:28 +0100 Subject: Disable outputs in rootston config --- include/rootston/config.h | 1 + rootston/config.c | 11 ++++++++++- rootston/output.c | 21 +++++++++++++-------- 3 files changed, 24 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/rootston/config.h b/include/rootston/config.h index bd24e577..05f23b75 100644 --- a/include/rootston/config.h +++ b/include/rootston/config.h @@ -7,6 +7,7 @@ struct roots_output_config { char *name; + bool enable; enum wl_output_transform transform; int x, y; float scale; diff --git a/rootston/config.c b/rootston/config.c index f9fde369..31bde2b0 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -263,10 +263,19 @@ static int config_ini_handler(void *user, const char *section, const char *name, oc->name = strdup(output_name); oc->transform = WL_OUTPUT_TRANSFORM_NORMAL; oc->scale = 1; + oc->enable = true; wl_list_insert(&config->outputs, &oc->link); } - if (strcmp(name, "x") == 0) { + if (strcmp(name, "enable") == 0) { + if (strcasecmp(value, "true") == 0) { + oc->enable = true; + } else if (strcasecmp(value, "false") == 0) { + oc->enable = false; + } else { + wlr_log(L_ERROR, "got invalid output enable value: %s", value); + } + } else if (strcmp(name, "x") == 0) { oc->x = strtol(value, NULL, 10); } else if (strcmp(name, "y") == 0) { oc->y = strtol(value, NULL, 10); diff --git a/rootston/output.c b/rootston/output.c index 10450df3..7e05136a 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -324,9 +324,10 @@ void output_add_notify(struct wl_listener *listener, void *data) { wlr_log(L_DEBUG, "'%s %s %s' %"PRId32"mm x %"PRId32"mm", wlr_output->make, wlr_output->model, wlr_output->serial, wlr_output->phys_width, wlr_output->phys_height); + if (wl_list_length(&wlr_output->modes) > 0) { - struct wlr_output_mode *mode = NULL; - mode = wl_container_of((&wlr_output->modes)->prev, mode, link); + struct wlr_output_mode *mode = + wl_container_of((&wlr_output->modes)->prev, mode, link); wlr_output_set_mode(wlr_output, mode); } @@ -341,13 +342,17 @@ void output_add_notify(struct wl_listener *listener, void *data) { struct roots_output_config *output_config = roots_config_get_output(config, wlr_output); if (output_config) { - if (output_config->mode.width) { - set_mode(wlr_output, output_config); + if (output_config->enable) { + if (output_config->mode.width) { + set_mode(wlr_output, output_config); + } + wlr_output_set_scale(wlr_output, output_config->scale); + wlr_output_set_transform(wlr_output, output_config->transform); + wlr_output_layout_add(desktop->layout, wlr_output, output_config->x, + output_config->y); + } else { + wlr_output_enable(wlr_output, false); } - wlr_output_set_scale(wlr_output, output_config->scale); - wlr_output_set_transform(wlr_output, output_config->transform); - wlr_output_layout_add(desktop->layout, wlr_output, output_config->x, - output_config->y); } else { wlr_output_layout_add_auto(desktop->layout, wlr_output); } -- cgit v1.2.3 From 8ebd7d4dbebc89aedf5e08d30ebcb5326b92f80b Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 6 Jan 2018 12:42:32 +0100 Subject: output: rename resolution event to mode --- examples/support/shared.c | 2 +- include/wlr/types/wlr_output.h | 2 +- types/wlr_output.c | 4 ++-- types/wlr_output_layout.c | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/examples/support/shared.c b/examples/support/shared.c index f76e4389..6cfaa6aa 100644 --- a/examples/support/shared.c +++ b/examples/support/shared.c @@ -425,7 +425,7 @@ static void output_add_notify(struct wl_listener *listener, void *data) { ostate->frame.notify = output_frame_notify; ostate->resolution.notify = output_resolution_notify; wl_signal_add(&output->events.frame, &ostate->frame); - wl_signal_add(&output->events.resolution, &ostate->resolution); + wl_signal_add(&output->events.mode, &ostate->resolution); wl_list_insert(&state->outputs, &ostate->link); if (state->output_add_cb) { state->output_add_cb(ostate); diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index a726c4c8..71463cb5 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -65,7 +65,7 @@ struct wlr_output { struct wl_signal frame; struct wl_signal swap_buffers; struct wl_signal enable; - struct wl_signal resolution; + struct wl_signal mode; struct wl_signal scale; struct wl_signal transform; struct wl_signal destroy; diff --git a/types/wlr_output.c b/types/wlr_output.c index 4b842571..8194c17e 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -202,7 +202,7 @@ void wlr_output_update_custom_mode(struct wlr_output *output, int32_t width, wlr_output_send_current_mode_to_resource(resource); } - wl_signal_emit(&output->events.resolution, output); + wl_signal_emit(&output->events.mode, output); } void wlr_output_set_transform(struct wlr_output *output, @@ -270,8 +270,8 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, wl_list_init(&output->wl_resources); wl_signal_init(&output->events.frame); wl_signal_init(&output->events.swap_buffers); - wl_signal_init(&output->events.resolution); wl_signal_init(&output->events.enable); + wl_signal_init(&output->events.mode); wl_signal_init(&output->events.scale); wl_signal_init(&output->events.transform); wl_signal_init(&output->events.destroy); diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index 7e782399..9b9b0c68 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -19,7 +19,7 @@ struct wlr_output_layout_output_state { bool auto_configured; struct wl_listener enable; - struct wl_listener resolution; + struct wl_listener mode; struct wl_listener scale; struct wl_listener transform; struct wl_listener output_destroy; @@ -49,7 +49,7 @@ static void wlr_output_layout_output_destroy( struct wlr_output_layout_output *l_output) { wl_signal_emit(&l_output->events.destroy, l_output); wl_list_remove(&l_output->state->enable.link); - wl_list_remove(&l_output->state->resolution.link); + wl_list_remove(&l_output->state->mode.link); wl_list_remove(&l_output->state->scale.link); wl_list_remove(&l_output->state->transform.link); wl_list_remove(&l_output->state->output_destroy.link); @@ -150,9 +150,9 @@ static void handle_output_enable(struct wl_listener *listener, void *data) { wlr_output_layout_reconfigure(state->layout); } -static void handle_output_resolution(struct wl_listener *listener, void *data) { +static void handle_output_mode(struct wl_listener *listener, void *data) { struct wlr_output_layout_output_state *state = - wl_container_of(listener, state, resolution); + wl_container_of(listener, state, mode); wlr_output_layout_reconfigure(state->layout); } @@ -196,8 +196,8 @@ static struct wlr_output_layout_output *wlr_output_layout_output_create( wl_signal_add(&output->events.enable, &l_output->state->enable); l_output->state->enable.notify = handle_output_enable; - wl_signal_add(&output->events.resolution, &l_output->state->resolution); - l_output->state->resolution.notify = handle_output_resolution; + wl_signal_add(&output->events.mode, &l_output->state->mode); + l_output->state->mode.notify = handle_output_mode; wl_signal_add(&output->events.scale, &l_output->state->scale); l_output->state->scale.notify = handle_output_scale; wl_signal_add(&output->events.transform, &l_output->state->transform); -- 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 'include') 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