aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/atomic.c38
-rw-r--r--backend/drm/drm.c14
-rw-r--r--backend/drm/legacy.c5
-rw-r--r--backend/headless/backend.c2
-rw-r--r--backend/headless/output.c5
-rw-r--r--backend/wayland/output.c5
-rw-r--r--backend/x11/backend.c8
7 files changed, 49 insertions, 28 deletions
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c
index 64fae6e4..54024d86 100644
--- a/backend/drm/atomic.c
+++ b/backend/drm/atomic.c
@@ -33,7 +33,6 @@ static bool atomic_end(int drm_fd, struct atomic *atom) {
}
uint32_t flags = DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_NONBLOCK;
-
if (drmModeAtomicCommit(drm_fd, atom->req, flags, NULL)) {
wlr_log_errno(L_ERROR, "Atomic test failed");
drmModeAtomicSetCursor(atom->req, atom->cursor);
@@ -44,13 +43,11 @@ static bool atomic_end(int drm_fd, struct atomic *atom) {
}
static bool atomic_commit(int drm_fd, struct atomic *atom,
- struct wlr_drm_connector *conn, uint32_t flag, bool modeset) {
+ struct wlr_drm_connector *conn, uint32_t flags, bool modeset) {
if (atom->failed) {
return false;
}
- uint32_t flags = DRM_MODE_PAGE_FLIP_EVENT | flag;
-
int ret = drmModeAtomicCommit(drm_fd, atom->req, flags, conn);
if (ret) {
wlr_log_errno(L_ERROR, "%s: Atomic commit failed (%s)",
@@ -59,7 +56,8 @@ static bool atomic_commit(int drm_fd, struct atomic *atom,
// Try to commit without new changes
drmModeAtomicSetCursor(atom->req, atom->cursor);
if (drmModeAtomicCommit(drm_fd, atom->req, flags, conn)) {
- wlr_log_errno(L_ERROR, "%s: Atomic commit failed (%s)",
+ wlr_log_errno(L_ERROR,
+ "%s: Atomic commit without new changes failed (%s)",
conn->output.name, modeset ? "modeset" : "pageflip");
}
}
@@ -100,8 +98,8 @@ static bool atomic_crtc_pageflip(struct wlr_drm_backend *drm,
struct wlr_drm_connector *conn,
struct wlr_drm_crtc *crtc,
uint32_t fb_id, drmModeModeInfo *mode) {
- if (mode) {
- if (crtc->mode_id) {
+ if (mode != NULL) {
+ if (crtc->mode_id != 0) {
drmModeDestroyPropertyBlob(drm->fd, crtc->mode_id);
}
@@ -111,26 +109,38 @@ static bool atomic_crtc_pageflip(struct wlr_drm_backend *drm,
}
}
- struct atomic atom;
+ uint32_t flags = DRM_MODE_PAGE_FLIP_EVENT;
+ if (mode != NULL) {
+ flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
+ } else {
+ flags |= DRM_MODE_ATOMIC_NONBLOCK;
+ }
+ struct atomic atom;
atomic_begin(crtc, &atom);
atomic_add(&atom, conn->id, conn->props.crtc_id, crtc->id);
atomic_add(&atom, crtc->id, crtc->props.mode_id, crtc->mode_id);
atomic_add(&atom, crtc->id, crtc->props.active, 1);
set_plane_props(&atom, crtc->primary, crtc->id, fb_id, true);
- return atomic_commit(drm->fd, &atom, conn,
- mode ? DRM_MODE_ATOMIC_ALLOW_MODESET : DRM_MODE_ATOMIC_NONBLOCK,
- mode);
+ return atomic_commit(drm->fd, &atom, conn, flags, 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 dd5c97f5..0d32605a 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -252,11 +252,16 @@ 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);
}
+
+ wlr_output_update_enabled(&conn->output, enable);
}
static void realloc_planes(struct wlr_drm_backend *drm, const uint32_t *crtc_in,
@@ -722,7 +727,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 +798,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 +808,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);
}
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/backend/headless/backend.c b/backend/headless/backend.c
index f95e3897..cef8eec4 100644
--- a/backend/headless/backend.c
+++ b/backend/headless/backend.c
@@ -15,7 +15,7 @@ static bool backend_start(struct wlr_backend *wlr_backend) {
struct wlr_headless_output *output;
wl_list_for_each(output, &backend->outputs, link) {
wl_event_source_timer_update(output->frame_timer, output->frame_delay);
- wlr_output_create_global(&output->wlr_output, backend->display);
+ wlr_output_update_enabled(&output->wlr_output, true);
wl_signal_emit(&backend->backend.events.output_add,
&output->wlr_output);
}
diff --git a/backend/headless/output.c b/backend/headless/output.c
index 511c2c53..9fc92e88 100644
--- a/backend/headless/output.c
+++ b/backend/headless/output.c
@@ -105,7 +105,8 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
return NULL;
}
output->backend = backend;
- wlr_output_init(&output->wlr_output, &backend->backend, &output_impl);
+ wlr_output_init(&output->wlr_output, &backend->backend, &output_impl,
+ backend->display);
struct wlr_output *wlr_output = &output->wlr_output;
output->egl_surface = egl_create_surface(&backend->egl, width, height);
@@ -138,7 +139,7 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
if (backend->started) {
wl_event_source_timer_update(output->frame_timer, output->frame_delay);
- wlr_output_create_global(wlr_output, backend->display);
+ wlr_output_update_enabled(wlr_output, true);
wl_signal_emit(&backend->backend.events.output_add, wlr_output);
}
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index d76f6366..52791679 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -261,7 +261,8 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
wlr_log(L_ERROR, "Failed to allocate wlr_wl_backend_output");
return NULL;
}
- wlr_output_init(&output->wlr_output, &backend->backend, &output_impl);
+ wlr_output_init(&output->wlr_output, &backend->backend, &output_impl,
+ backend->local_display);
struct wlr_output *wlr_output = &output->wlr_output;
wlr_output_update_custom_mode(wlr_output, 1280, 720, 0);
@@ -325,7 +326,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
}
wl_list_insert(&backend->outputs, &output->link);
- wlr_output_create_global(wlr_output, backend->local_display);
+ wlr_output_update_enabled(wlr_output, true);
wl_signal_emit(&backend->backend.events.output_add, wlr_output);
return wlr_output;
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index d2690342..e1622d06 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -181,7 +181,8 @@ static int signal_frame(void *data) {
static void init_atom(struct wlr_x11_backend *x11, struct wlr_x11_atom *atom,
uint8_t only_if_exists, const char *name) {
- atom->cookie = xcb_intern_atom(x11->xcb_conn, only_if_exists, strlen(name), name);
+ atom->cookie = xcb_intern_atom(x11->xcb_conn, only_if_exists, strlen(name),
+ name);
atom->reply = xcb_intern_atom_reply(x11->xcb_conn, atom->cookie, NULL);
}
@@ -201,7 +202,8 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
output->x11 = x11;
- wlr_output_init(&output->wlr_output, &x11->backend, &output_impl);
+ wlr_output_init(&output->wlr_output, &x11->backend, &output_impl,
+ x11->wl_display);
snprintf(output->wlr_output.name, sizeof(output->wlr_output.name), "X11-1");
output->win = xcb_generate_id(x11->xcb_conn);
@@ -224,7 +226,7 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
xcb_map_window(x11->xcb_conn, output->win);
xcb_flush(x11->xcb_conn);
- wlr_output_create_global(&output->wlr_output, x11->wl_display);
+ wlr_output_update_enabled(&output->wlr_output, true);
wl_signal_emit(&x11->backend.events.output_add, output);
wl_signal_emit(&x11->backend.events.input_add, &x11->keyboard_dev);