compositor-drm: remove unused_connectors array

Replace the unused_connectors array by iterating through the head list
instead. A head that is not enabled (attached to an enabled output) is
basically an unused connector.

All connectors regardless of their status have a drm_head. This has the
nice effect that drm_pending_state_apply_atomic() does not need to
re-query the connector properties every time, they can be simply looked
up in the drm_head.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
dev
Pekka Paalanen 7 years ago
parent d2e6242e3c
commit eacec815a3
  1. 61
      libweston/compositor-drm.c

@ -252,8 +252,7 @@ struct drm_backend {
bool state_invalid; bool state_invalid;
/* Connector and CRTC IDs not used by any enabled output. */ /* CRTC IDs not used by any enabled output. */
struct wl_array unused_connectors;
struct wl_array unused_crtcs; struct wl_array unused_crtcs;
int cursors_are_broken; int cursors_are_broken;
@ -2124,47 +2123,36 @@ drm_pending_state_apply_atomic(struct drm_pending_state *pending_state,
return -1; return -1;
if (b->state_invalid) { if (b->state_invalid) {
struct weston_head *head_base;
struct drm_head *head;
uint32_t *unused; uint32_t *unused;
int err; int err;
/* If we need to reset all our state (e.g. because we've /* If we need to reset all our state (e.g. because we've
* just started, or just been VT-switched in), explicitly * just started, or just been VT-switched in), explicitly
* disable all the CRTCs and connectors we aren't using. */ * disable all the CRTCs and connectors we aren't using. */
wl_array_for_each(unused, &b->unused_connectors) { wl_list_for_each(head_base,
struct drm_property_info infos[WDRM_CONNECTOR__COUNT]; &b->compositor->head_list, compositor_link) {
struct drm_property_info *info; struct drm_property_info *info;
drmModeObjectProperties *props;
memset(infos, 0, sizeof(infos));
props = drmModeObjectGetProperties(b->drm.fd, if (weston_head_is_enabled(head_base))
*unused,
DRM_MODE_OBJECT_CONNECTOR);
if (!props) {
ret = -1;
continue; continue;
}
drm_property_info_populate(b, connector_props, infos, head = to_drm_head(head_base);
WDRM_CONNECTOR__COUNT,
props);
drmModeFreeObjectProperties(props);
info = &infos[WDRM_CONNECTOR_CRTC_ID]; info = &head->props_conn[WDRM_CONNECTOR_CRTC_ID];
err = drmModeAtomicAddProperty(req, *unused, err = drmModeAtomicAddProperty(req, head->connector_id,
info->prop_id, 0); info->prop_id, 0);
if (err <= 0) if (err <= 0)
ret = -1; ret = -1;
info = &infos[WDRM_CONNECTOR_DPMS]; info = &head->props_conn[WDRM_CONNECTOR_DPMS];
if (info->prop_id > 0) if (info->prop_id > 0)
err = drmModeAtomicAddProperty(req, *unused, err = drmModeAtomicAddProperty(req, head->connector_id,
info->prop_id, info->prop_id,
DRM_MODE_DPMS_OFF); DRM_MODE_DPMS_OFF);
if (err <= 0) if (err <= 0)
ret = -1; ret = -1;
drm_property_info_free(infos, WDRM_CONNECTOR__COUNT);
} }
wl_array_for_each(unused, &b->unused_crtcs) { wl_array_for_each(unused, &b->unused_crtcs) {
@ -4828,8 +4816,6 @@ drm_output_enable(struct weston_output *base)
&output->scanout_plane->base, &output->scanout_plane->base,
&b->compositor->primary_plane); &b->compositor->primary_plane);
wl_array_remove_uint32(&b->unused_connectors, head->connector_id);
weston_log("Output %s, (connector %d, crtc %d)\n", weston_log("Output %s, (connector %d, crtc %d)\n",
output->base.name, head->connector_id, output->crtc_id); output->base.name, head->connector_id, output->crtc_id);
wl_list_for_each(m, &output->base.mode_list, link) wl_list_for_each(m, &output->base.mode_list, link)
@ -4854,9 +4840,7 @@ static void
drm_output_deinit(struct weston_output *base) drm_output_deinit(struct weston_output *base)
{ {
struct drm_output *output = to_drm_output(base); struct drm_output *output = to_drm_output(base);
struct drm_head *head = to_drm_head(weston_output_get_first_head(base));
struct drm_backend *b = to_drm_backend(base->compositor); struct drm_backend *b = to_drm_backend(base->compositor);
uint32_t *unused;
if (b->use_pixman) if (b->use_pixman)
drm_output_fini_pixman(output); drm_output_fini_pixman(output);
@ -4879,9 +4863,6 @@ drm_output_deinit(struct weston_output *base)
} }
} }
unused = wl_array_add(&b->unused_connectors, sizeof(*unused));
*unused = head->connector_id;
drm_output_fini_crtc(output); drm_output_fini_crtc(output);
} }
@ -4941,7 +4922,7 @@ drm_output_disable(struct weston_output *base)
/** /**
* Update the list of unused connectors and CRTCs * Update the list of unused connectors and CRTCs
* *
* This keeps the unused_connectors and unused_crtcs arrays up to date. * This keeps the unused_crtc arrays up to date.
* *
* @param b Weston backend structure * @param b Weston backend structure
* @param resources DRM resources for this device * @param resources DRM resources for this device
@ -4951,22 +4932,6 @@ drm_backend_update_unused_outputs(struct drm_backend *b, drmModeRes *resources)
{ {
int i; int i;
wl_array_release(&b->unused_connectors);
wl_array_init(&b->unused_connectors);
for (i = 0; i < resources->count_connectors; i++) {
struct drm_head *head;
uint32_t *connector_id;
head = drm_head_find_by_connector(b, resources->connectors[i]);
if (head && weston_head_is_enabled(&head->base))
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_release(&b->unused_crtcs);
wl_array_init(&b->unused_crtcs); wl_array_init(&b->unused_crtcs);
@ -5344,7 +5309,6 @@ drm_destroy(struct weston_compositor *ec)
weston_launcher_destroy(ec->launcher); weston_launcher_destroy(ec->launcher);
wl_array_release(&b->unused_crtcs); wl_array_release(&b->unused_crtcs);
wl_array_release(&b->unused_connectors);
close(b->drm.fd); close(b->drm.fd);
free(b->drm.filename); free(b->drm.filename);
@ -5778,7 +5742,6 @@ drm_backend_create(struct weston_compositor *compositor,
b->state_invalid = true; b->state_invalid = true;
b->drm.fd = -1; b->drm.fd = -1;
wl_array_init(&b->unused_crtcs); wl_array_init(&b->unused_crtcs);
wl_array_init(&b->unused_connectors);
/* /*
* KMS support for hardware planes cannot properly synchronize * KMS support for hardware planes cannot properly synchronize

Loading…
Cancel
Save