From dd0ad3bfb1fae1b7993bc36a71e69af1cb2f0c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 4 Aug 2020 19:28:04 +0200 Subject: [PATCH] kms/impl-device: Only update crtc/connector whose ID has changed On hotplug events we may get informations about what CRTC or connector changed a property (and the property itself), so in such case let's just ignore the changes to the non-affected CRTCs/connectors, and let's read only the affected one Part-of: --- src/backends/native/meta-kms-device-private.h | 4 ++- src/backends/native/meta-kms-device.c | 7 ++++-- src/backends/native/meta-kms-impl-device.c | 25 ++++++++++++++++--- src/backends/native/meta-kms-impl-device.h | 4 ++- src/backends/native/meta-kms.c | 5 +++- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/backends/native/meta-kms-device-private.h b/src/backends/native/meta-kms-device-private.h index 1079741e0..f7d810af0 100644 --- a/src/backends/native/meta-kms-device-private.h +++ b/src/backends/native/meta-kms-device-private.h @@ -25,7 +25,9 @@ MetaKmsImplDevice * meta_kms_device_get_impl_device (MetaKmsDevice *device); -MetaKmsUpdateChanges meta_kms_device_update_states_in_impl (MetaKmsDevice *device); +MetaKmsUpdateChanges meta_kms_device_update_states_in_impl (MetaKmsDevice *device, + uint32_t crtc_id, + uint32_t connector_id); void meta_kms_device_predict_states_in_impl (MetaKmsDevice *device, MetaKmsUpdate *update); diff --git a/src/backends/native/meta-kms-device.c b/src/backends/native/meta-kms-device.c index 6085654ba..f44260a31 100644 --- a/src/backends/native/meta-kms-device.c +++ b/src/backends/native/meta-kms-device.c @@ -231,7 +231,9 @@ meta_kms_device_get_fallback_modes (MetaKmsDevice *device) } MetaKmsUpdateChanges -meta_kms_device_update_states_in_impl (MetaKmsDevice *device) +meta_kms_device_update_states_in_impl (MetaKmsDevice *device, + uint32_t crtc_id, + uint32_t connector_id) { MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device); MetaKmsUpdateChanges changes; @@ -239,7 +241,8 @@ meta_kms_device_update_states_in_impl (MetaKmsDevice *device) meta_assert_in_kms_impl (device->kms); meta_assert_is_waiting_for_kms_impl_task (device->kms); - changes = meta_kms_impl_device_update_states (impl_device); + changes = meta_kms_impl_device_update_states (impl_device, crtc_id, + connector_id); if (changes == META_KMS_UPDATE_CHANGE_NONE) return changes; diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c index e616ffd2a..94f7892ee 100644 --- a/src/backends/native/meta-kms-impl-device.c +++ b/src/backends/native/meta-kms-impl-device.c @@ -702,7 +702,9 @@ clear_latched_fd_hold (MetaKmsImplDevice *impl_device) } MetaKmsUpdateChanges -meta_kms_impl_device_update_states (MetaKmsImplDevice *impl_device) +meta_kms_impl_device_update_states (MetaKmsImplDevice *impl_device, + uint32_t crtc_id, + uint32_t connector_id) { MetaKmsImplDevicePrivate *priv = meta_kms_impl_device_get_instance_private (impl_device); @@ -736,11 +738,26 @@ meta_kms_impl_device_update_states (MetaKmsImplDevice *impl_device) changes = update_connectors (impl_device, drm_resources); for (l = priv->crtcs; l; l = l->next) - changes |= meta_kms_crtc_update_state (META_KMS_CRTC (l->data)); + { + MetaKmsCrtc *crtc = META_KMS_CRTC (l->data); + + if (crtc_id > 0 && + meta_kms_crtc_get_id (crtc) != crtc_id) + continue; + + changes |= meta_kms_crtc_update_state (crtc); + } for (l = priv->connectors; l; l = l->next) - changes |= meta_kms_connector_update_state (META_KMS_CONNECTOR (l->data), - drm_resources); + { + MetaKmsConnector *connector = META_KMS_CONNECTOR (l->data); + + if (connector_id > 0 && + meta_kms_connector_get_id (connector) != connector_id) + continue; + + changes |= meta_kms_connector_update_state (connector, drm_resources); + } drmModeFreeResources (drm_resources); diff --git a/src/backends/native/meta-kms-impl-device.h b/src/backends/native/meta-kms-impl-device.h index caddae3c1..4710f00bd 100644 --- a/src/backends/native/meta-kms-impl-device.h +++ b/src/backends/native/meta-kms-impl-device.h @@ -135,7 +135,9 @@ void meta_kms_impl_device_hold_fd (MetaKmsImplDevice *impl_device); void meta_kms_impl_device_unhold_fd (MetaKmsImplDevice *impl_device); -MetaKmsUpdateChanges meta_kms_impl_device_update_states (MetaKmsImplDevice *impl_device); +MetaKmsUpdateChanges meta_kms_impl_device_update_states (MetaKmsImplDevice *impl_device, + uint32_t crtc_id, + uint32_t connector_id); void meta_kms_impl_device_predict_states (MetaKmsImplDevice *impl_device, MetaKmsUpdate *update); diff --git a/src/backends/native/meta-kms.c b/src/backends/native/meta-kms.c index e76aaca15..a1d483760 100644 --- a/src/backends/native/meta-kms.c +++ b/src/backends/native/meta-kms.c @@ -605,7 +605,10 @@ meta_kms_update_states_in_impl (MetaKms *kms, update_data->connector_id)) continue; - changes |= meta_kms_device_update_states_in_impl (kms_device); + changes |= + meta_kms_device_update_states_in_impl (kms_device, + update_data->crtc_id, + update_data->connector_id); } return changes;