[PATCH weston 3/3] compositor-drm: Remove connector_allocator
Daniel Stone
daniels at collabora.com
Thu Feb 9 14:54:28 UTC 2017
Remove the last usage of connector_allocator, which was to check for
displays which have been hot-unplugged, and replace it with an array
which doesn't rely on the connector IDs remaining below 32 (or 64).
Signed-off-by: Daniel Stone <daniels at collabora.com>
Reported-by: Peter Senna Tschudin <peter.senna at collabora.com>
---
libweston/compositor-drm.c | 64 +++++++++++++++++++++++++++++-----------------
1 file changed, 40 insertions(+), 24 deletions(-)
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 90f91006a..5e9449644 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -94,7 +94,6 @@ struct drm_backend {
char *filename;
} drm;
struct gbm_device *gbm;
- uint32_t connector_allocator;
struct wl_listener session_listener;
uint32_t gbm_format;
@@ -2528,8 +2527,6 @@ drm_output_destroy(struct weston_output *base)
if (output->backlight)
backlight_destroy(output->backlight);
- b->connector_allocator &= ~(1 << output->connector_id);
-
free(output);
}
@@ -2605,8 +2602,6 @@ create_output_for_connector(struct drm_backend *b,
output->disable_pending = 0;
output->original_crtc = NULL;
- b->connector_allocator |= (1 << output->connector_id);
-
weston_output_init(&output->base, b->compositor);
weston_compositor_add_pending_output(&output->base, b->compositor);
@@ -2734,7 +2729,7 @@ update_outputs(struct drm_backend *b, struct udev_device *drm_device)
drmModeConnector *connector;
drmModeRes *resources;
struct drm_output *output, *next;
- uint32_t connected = 0, disconnects = 0;
+ uint32_t *connected;
int i;
resources = drmModeGetResources(b->drm.fd);
@@ -2743,6 +2738,12 @@ update_outputs(struct drm_backend *b, struct udev_device *drm_device)
return;
}
+ connected = calloc(resources->count_connectors, sizeof(uint32_t));
+ if (!connected) {
+ drmModeFreeResources(resources);
+ return;
+ }
+
/* collect new connects */
for (i = 0; i < resources->count_connectors; i++) {
uint32_t connector_id = resources->connectors[i];
@@ -2763,7 +2764,7 @@ update_outputs(struct drm_backend *b, struct udev_device *drm_device)
continue;
}
- connected |= (1 << connector_id);
+ connected[i] = connector_id;
wl_list_for_each(tmp, &b->compositor->output_list, base.link) {
if (tmp->connector_id == connector_id) {
@@ -2787,30 +2788,45 @@ update_outputs(struct drm_backend *b, struct udev_device *drm_device)
connector, drm_device);
weston_log("connector %d connected\n", connector_id);
}
- drmModeFreeResources(resources);
- disconnects = b->connector_allocator & ~connected;
- if (disconnects) {
- wl_list_for_each_safe(output, next, &b->compositor->output_list,
- base.link) {
- if (disconnects & (1 << output->connector_id)) {
- disconnects &= ~(1 << output->connector_id);
- weston_log("connector %d disconnected\n",
- output->connector_id);
- drm_output_destroy(&output->base);
+ wl_list_for_each_safe(output, next, &b->compositor->output_list,
+ base.link) {
+ bool disconnected = true;
+
+ for (i = 0; i < resources->count_connectors; i++) {
+ if (connected[i] == output->connector_id) {
+ disconnected = false;
+ break;
}
}
- wl_list_for_each_safe(output, next, &b->compositor->pending_output_list,
- base.link) {
- if (disconnects & (1 << output->connector_id)) {
- disconnects &= ~(1 << output->connector_id);
- weston_log("connector %d disconnected\n",
- output->connector_id);
- drm_output_destroy(&output->base);
+ if (!disconnected)
+ continue;
+
+ weston_log("connector %d disconnected\n", output->connector_id);
+ drm_output_destroy(&output->base);
+ }
+
+ wl_list_for_each_safe(output, next, &b->compositor->pending_output_list,
+ base.link) {
+ bool disconnected = true;
+
+ for (i = 0; i < resources->count_connectors; i++) {
+ if (connected[i] == output->connector_id) {
+ disconnected = false;
+ break;
}
}
+
+ if (!disconnected)
+ continue;
+
+ weston_log("connector %d disconnected\n", output->connector_id);
+ drm_output_destroy(&output->base);
}
+
+ free(connected);
+ drmModeFreeResources(resources);
}
static int
--
2.11.0
More information about the wayland-devel
mailing list