From fc0a74a4c9732b0cddac51eccae14069d6040c59 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 31 Aug 2023 15:23:25 +0300 Subject: [PATCH] backend-drm: skip EDID parsing if no change Performance-wise this is moot, but since we are detecting if the raw EDID data changed, might as well use it. Now we have a path where the head's device_changed is almost guaranteed since EDID changed, and that's useful for the next patch. We can only do this, because the core initializes a head with values that we would be setting anyway when EDID is missing, e.g. disconnected head on compositor start-up. Signed-off-by: Pekka Paalanen --- libweston/backend-drm/modes.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/libweston/backend-drm/modes.c b/libweston/backend-drm/modes.c index b4ade8cc6..e77fbe6c7 100644 --- a/libweston/backend-drm/modes.c +++ b/libweston/backend-drm/modes.c @@ -613,18 +613,7 @@ update_head_from_connector(struct drm_head *head) struct drm_connector *connector = &head->connector; drmModeObjectProperties *props = connector->props_drm; drmModeConnector *conn = connector->conn; - struct drm_head_info dhi = { .eotf_mask = WESTON_EOTF_MODE_SDR }; - drm_head_maybe_update_display_data(head, props); - - drm_head_info_from_edid(&dhi, head->display_data, head->display_data_len); - - weston_head_set_monitor_strings(&head->base, dhi.make, - dhi.model, - dhi.serial_number); - - prune_eotf_modes_by_kms_support(head, &dhi.eotf_mask); - weston_head_set_supported_eotf_mask(&head->base, dhi.eotf_mask); weston_head_set_non_desktop(&head->base, check_non_desktop(connector, props)); weston_head_set_subpixel(&head->base, @@ -639,6 +628,21 @@ update_head_from_connector(struct drm_head *head) weston_head_set_connection_status(&head->base, conn->connection == DRM_MODE_CONNECTED); + /* If EDID did not change, skip everything about it */ + if (!drm_head_maybe_update_display_data(head, props)) + return; + + struct drm_head_info dhi = { .eotf_mask = WESTON_EOTF_MODE_SDR }; + + drm_head_info_from_edid(&dhi, head->display_data, head->display_data_len); + + weston_head_set_monitor_strings(&head->base, dhi.make, + dhi.model, + dhi.serial_number); + + prune_eotf_modes_by_kms_support(head, &dhi.eotf_mask); + weston_head_set_supported_eotf_mask(&head->base, dhi.eotf_mask); + drm_head_info_fini(&dhi); }