From 99fb2fefc340278b29c3af9a53a319059599c8c7 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 6 Dec 2022 18:50:53 +0100 Subject: [PATCH] backend/drm: rename wlr_drm_backend.outputs to connectors This list contains wlr_drm_connector entries, and there is no guarantee that the wlr_output fields are initialized. --- backend/drm/backend.c | 6 +++--- backend/drm/drm.c | 36 ++++++++++++++++++------------------ include/backend/drm/drm.h | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/backend/drm/backend.c b/backend/drm/backend.c index fc383832..1492c4d4 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -33,7 +33,7 @@ static void backend_destroy(struct wlr_backend *backend) { struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend); struct wlr_drm_connector *conn, *next; - wl_list_for_each_safe(conn, next, &drm->outputs, link) { + wl_list_for_each_safe(conn, next, &drm->connectors, link) { destroy_drm_connector(conn); } @@ -104,7 +104,7 @@ static void handle_session_active(struct wl_listener *listener, void *data) { scan_drm_connectors(drm, NULL); struct wlr_drm_connector *conn; - wl_list_for_each(conn, &drm->outputs, link) { + wl_list_for_each(conn, &drm->connectors, link) { struct wlr_output_mode *mode = NULL; uint32_t committed = WLR_OUTPUT_STATE_ENABLED; if (conn->status != DRM_MODE_DISCONNECTED && conn->output.enabled @@ -195,7 +195,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, drm->session = session; wl_list_init(&drm->fbs); - wl_list_init(&drm->outputs); + wl_list_init(&drm->connectors); drm->dev = dev; drm->fd = dev->fd; diff --git a/backend/drm/drm.c b/backend/drm/drm.c index f1ecd8c8..919d9821 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -1029,15 +1029,15 @@ static void realloc_crtcs(struct wlr_drm_backend *drm, struct wlr_drm_connector *want_conn) { assert(drm->num_crtcs > 0); - size_t num_outputs = wl_list_length(&drm->outputs); - if (num_outputs == 0) { + size_t num_connectors = wl_list_length(&drm->connectors); + if (num_connectors == 0) { return; } wlr_log(WLR_DEBUG, "Reallocating CRTCs"); - struct wlr_drm_connector *connectors[num_outputs]; - uint32_t connector_constraints[num_outputs]; + struct wlr_drm_connector *connectors[num_connectors]; + uint32_t connector_constraints[num_connectors]; uint32_t previous_match[drm->num_crtcs]; uint32_t new_match[drm->num_crtcs]; @@ -1048,7 +1048,7 @@ static void realloc_crtcs(struct wlr_drm_backend *drm, wlr_log(WLR_DEBUG, "State before reallocation:"); size_t i = 0; struct wlr_drm_connector *conn; - wl_list_for_each(conn, &drm->outputs, link) { + wl_list_for_each(conn, &drm->connectors, link) { connectors[i] = conn; if (conn->crtc) { @@ -1073,12 +1073,12 @@ static void realloc_crtcs(struct wlr_drm_backend *drm, ++i; } - match_obj(num_outputs, connector_constraints, + match_obj(num_connectors, connector_constraints, drm->num_crtcs, previous_match, new_match); // Converts our crtc=>connector result into a connector=>crtc one. - ssize_t connector_match[num_outputs]; - for (size_t i = 0 ; i < num_outputs; ++i) { + ssize_t connector_match[num_connectors]; + for (size_t i = 0 ; i < num_connectors; ++i) { connector_match[i] = -1; } for (size_t i = 0; i < drm->num_crtcs; ++i) { @@ -1092,7 +1092,7 @@ static void realloc_crtcs(struct wlr_drm_backend *drm, * match everything, we prefer to fail the new connector and keep all * of the old mappings instead. */ - for (size_t i = 0; i < num_outputs; ++i) { + for (size_t i = 0; i < num_connectors; ++i) { struct wlr_drm_connector *conn = connectors[i]; if (conn->status == DRM_MODE_CONNECTED && conn->output.enabled && connector_match[i] == -1) { @@ -1104,7 +1104,7 @@ static void realloc_crtcs(struct wlr_drm_backend *drm, wlr_log(WLR_DEBUG, "State after reallocation:"); // Apply new configuration - for (size_t i = 0; i < num_outputs; ++i) { + for (size_t i = 0; i < num_connectors; ++i) { struct wlr_drm_connector *conn = connectors[i]; bool prev_enabled = conn->crtc; @@ -1200,7 +1200,7 @@ static struct wlr_drm_connector *create_drm_connector(struct wlr_drm_backend *dr wlr_conn->crtc = connector_get_current_crtc(wlr_conn, drm_conn); - wl_list_insert(drm->outputs.prev, &wlr_conn->link); + wl_list_insert(drm->connectors.prev, &wlr_conn->link); return wlr_conn; } @@ -1364,7 +1364,7 @@ void scan_drm_connectors(struct wlr_drm_backend *drm, return; } - size_t seen_len = wl_list_length(&drm->outputs); + size_t seen_len = wl_list_length(&drm->connectors); // +1 so length can never be 0, which is undefined behaviour. // Last element isn't used. bool seen[seen_len + 1]; @@ -1377,7 +1377,7 @@ void scan_drm_connectors(struct wlr_drm_backend *drm, ssize_t index = -1; struct wlr_drm_connector *c, *wlr_conn = NULL; - wl_list_for_each(c, &drm->outputs, link) { + wl_list_for_each(c, &drm->connectors, link) { index++; if (c->id == conn_id) { wlr_conn = c; @@ -1448,8 +1448,8 @@ void scan_drm_connectors(struct wlr_drm_backend *drm, // Iterate in reverse order because we'll remove items from the list and // still want indices to remain correct. struct wlr_drm_connector *conn, *tmp_conn; - size_t index = wl_list_length(&drm->outputs); - wl_list_for_each_reverse_safe(conn, tmp_conn, &drm->outputs, link) { + size_t index = wl_list_length(&drm->connectors); + wl_list_for_each_reverse_safe(conn, tmp_conn, &drm->connectors, link) { index--; if (index >= seen_len || seen[index]) { continue; @@ -1478,7 +1478,7 @@ void scan_drm_leases(struct wlr_drm_backend *drm) { } struct wlr_drm_connector *conn; - wl_list_for_each(conn, &drm->outputs, link) { + wl_list_for_each(conn, &drm->connectors, link) { if (conn->lease == NULL) { continue; } @@ -1510,7 +1510,7 @@ static void handle_page_flip(int fd, unsigned seq, bool found = false; struct wlr_drm_connector *conn; - wl_list_for_each(conn, &drm->outputs, link) { + wl_list_for_each(conn, &drm->connectors, link) { if (conn->pending_page_flip_crtc == crtc_id) { found = true; break; @@ -1721,7 +1721,7 @@ void drm_lease_destroy(struct wlr_drm_lease *lease) { wl_signal_emit_mutable(&lease->events.destroy, NULL); struct wlr_drm_connector *conn; - wl_list_for_each(conn, &drm->outputs, link) { + wl_list_for_each(conn, &drm->connectors, link) { if (conn->lease == lease) { conn->lease = NULL; } diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index fa18225c..16126ec2 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -75,7 +75,7 @@ struct wlr_drm_backend { struct wl_listener dev_remove; struct wl_list fbs; // wlr_drm_fb.link - struct wl_list outputs; + struct wl_list connectors; // wlr_drm_connector.link /* Only initialized on multi-GPU setups */ struct wlr_drm_renderer mgpu_renderer; @@ -122,7 +122,7 @@ struct wlr_drm_connector { /* Buffer to be submitted to the kernel on the next page-flip */ struct wlr_drm_fb *cursor_pending_fb; - struct wl_list link; + struct wl_list link; // wlr_drm_backend.connectors /* CRTC ID if a page-flip is pending, zero otherwise. *