kms/device: Add functions to find connector and crtc in devices

Hotplug events may contain CRTC or CONNECTOR ids to notify a property
change to just one owner, so we need to find its parent device.

Also we may want to update properties directly without having to go through
all the devices, so expose a simple way to find them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
This commit is contained in:
Marco Trevisan (Treviño) 2020-08-04 19:03:17 +02:00 committed by Marge Bot
parent ea00c96044
commit 3d3668a389
2 changed files with 50 additions and 0 deletions

View File

@ -34,4 +34,10 @@ void meta_kms_device_add_fake_plane_in_impl (MetaKmsDevice *device,
MetaKmsPlaneType plane_type,
MetaKmsCrtc *crtc);
MetaKmsCrtc * meta_kms_device_find_crtc_in_impl (MetaKmsDevice *device,
uint32_t crtc_id);
MetaKmsConnector * meta_kms_device_find_connector_in_impl (MetaKmsDevice *device,
uint32_t connector_id);
#endif /* META_KMS_DEVICE_PRIVATE_H */

View File

@ -20,6 +20,8 @@
#include "config.h"
#include "backends/native/meta-kms-connector.h"
#include "backends/native/meta-kms-crtc.h"
#include "backends/native/meta-kms-device-private.h"
#include "backends/native/meta-kms-device.h"
@ -133,6 +135,48 @@ meta_kms_device_get_connectors (MetaKmsDevice *device)
return device->connectors;
}
MetaKmsCrtc *
meta_kms_device_find_crtc_in_impl (MetaKmsDevice *device,
uint32_t crtc_id)
{
MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device);
GList *l;
meta_assert_in_kms_impl (device->kms);
meta_assert_is_waiting_for_kms_impl_task (device->kms);
for (l = meta_kms_impl_device_peek_crtcs (impl_device); l; l = l->next)
{
MetaKmsCrtc *crtc = META_KMS_CRTC (l->data);
if (meta_kms_crtc_get_id (crtc) == crtc_id)
return crtc;
}
return NULL;
}
MetaKmsConnector *
meta_kms_device_find_connector_in_impl (MetaKmsDevice *device,
uint32_t connector_id)
{
MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device);
GList *l;
meta_assert_in_kms_impl (device->kms);
meta_assert_is_waiting_for_kms_impl_task (device->kms);
for (l = meta_kms_impl_device_peek_connectors (impl_device); l; l = l->next)
{
MetaKmsConnector *connector = META_KMS_CONNECTOR (l->data);
if (meta_kms_connector_get_id (connector) == connector_id)
return connector;
}
return NULL;
}
GList *
meta_kms_device_get_crtcs (MetaKmsDevice *device)
{