Rather than a more piecemeal approach at backend creation, explicitly track connectors and CRTCs we do not intend to use, so we can ensure they are disabled where appropriate.
Signed-off-by: Daniel Stone <dani...@collabora.com> --- libweston/compositor-drm.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) v9: New. Required for atomic modesetting; see changelog in atomic patch. diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index 6337b9b..a487bb6 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -192,6 +192,9 @@ struct drm_backend { void *repaint_data; + struct wl_array unused_connectors; + struct wl_array unused_crtcs; + int cursors_are_broken; bool universal_planes; @@ -3928,6 +3931,47 @@ drm_output_disable(struct weston_output *base) } /** + * Update the list of unused connectors and CRTCs + * + * This keeps the unused_connectors and unused_crtcs arrays up to date. + * + * @param b Weston backend structure + * @param resources DRM resources for this device + */ +static void +drm_backend_update_unused_outputs(struct drm_backend *b, drmModeRes *resources) +{ + int i; + + wl_array_release(&b->unused_connectors); + wl_array_init(&b->unused_connectors); + + for (i = 0; i < resources->count_connectors; i++) { + uint32_t *connector_id; + + if (drm_output_find_by_connector(b, resources->connectors[i])) + continue; + + connector_id = wl_array_add(&b->unused_connectors, + sizeof(*connector_id)); + *connector_id = resources->connectors[i]; + } + + wl_array_release(&b->unused_crtcs); + wl_array_init(&b->unused_crtcs); + + for (i = 0; i < resources->count_crtcs; i++) { + uint32_t *crtc_id; + + if (drm_output_find_by_crtc(b, resources->crtcs[i])) + continue; + + crtc_id = wl_array_add(&b->unused_crtcs, sizeof(*crtc_id)); + *crtc_id = resources->crtcs[i]; + } +} + +/** * Create a Weston output structure * * Given a DRM connector, create a matching drm_output structure and add it @@ -4068,6 +4112,8 @@ create_outputs(struct drm_backend *b, struct udev_device *drm_device) drmModeFreeConnector(connector); } + drm_backend_update_unused_outputs(b, resources); + if (wl_list_empty(&b->compositor->output_list) && wl_list_empty(&b->compositor->pending_output_list)) weston_log("No currently active connector found.\n"); @@ -4176,6 +4222,8 @@ update_outputs(struct drm_backend *b, struct udev_device *drm_device) drm_output_destroy(&output->base); } + drm_backend_update_unused_outputs(b, resources); + free(connected); drmModeFreeResources(resources); } @@ -4240,6 +4288,9 @@ drm_destroy(struct weston_compositor *ec) weston_launcher_destroy(ec->launcher); + wl_array_release(&b->unused_crtcs); + wl_array_release(&b->unused_connectors); + close(b->drm.fd); free(b); } @@ -4642,6 +4693,8 @@ drm_backend_create(struct weston_compositor *compositor, return NULL; b->drm.fd = -1; + wl_array_init(&b->unused_crtcs); + wl_array_init(&b->unused_connectors); /* * KMS support for hardware planes cannot properly synchronize -- 2.9.3 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel