From fd598e186807755bf7a66e904c1ac240262ca843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 6 Aug 2024 21:11:54 +0200 Subject: [PATCH] kms: Add some debug logging for added planes/connectors/CRTCs Part-of: --- src/backends/native/meta-kms-connector.c | 6 +++ src/backends/native/meta-kms-crtc.c | 5 +++ .../native/meta-kms-impl-device-atomic.c | 12 +---- src/backends/native/meta-kms-plane.c | 44 ++++++++++++++++++- src/backends/native/meta-kms-plane.h | 2 + 5 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/backends/native/meta-kms-connector.c b/src/backends/native/meta-kms-connector.c index f3ed9931b..cc6cd89f5 100644 --- a/src/backends/native/meta-kms-connector.c +++ b/src/backends/native/meta-kms-connector.c @@ -1577,6 +1577,12 @@ meta_kms_connector_new (MetaKmsImplDevice *impl_device, connector->type_id = drm_connector->connector_type_id; connector->name = make_connector_name (drm_connector); + meta_topic (META_DEBUG_KMS, + "Adding connector %s (%u, %s)", + connector->name, + connector->id, + meta_kms_impl_device_get_path (impl_device)); + init_properties (connector, impl_device, drm_connector); meta_kms_connector_read_state (connector, impl_device, diff --git a/src/backends/native/meta-kms-crtc.c b/src/backends/native/meta-kms-crtc.c index 1fa16969e..7d4fac75b 100644 --- a/src/backends/native/meta-kms-crtc.c +++ b/src/backends/native/meta-kms-crtc.c @@ -509,6 +509,11 @@ meta_kms_crtc_new (MetaKmsImplDevice *impl_device, crtc->id = drm_crtc->crtc_id; crtc->idx = idx; + meta_topic (META_DEBUG_KMS, + "Adding CRTC %u (%s)", + crtc->id, + meta_kms_impl_device_get_path (impl_device)); + init_properties (crtc, impl_device, drm_crtc); meta_kms_crtc_read_state (crtc, impl_device, drm_crtc, drm_props); diff --git a/src/backends/native/meta-kms-impl-device-atomic.c b/src/backends/native/meta-kms-impl-device-atomic.c index e768fde34..2a4889a16 100644 --- a/src/backends/native/meta-kms-impl-device-atomic.c +++ b/src/backends/native/meta-kms-impl-device-atomic.c @@ -535,17 +535,7 @@ add_plane_property (MetaKmsImplDevice *impl_device, static const char * get_plane_type_string (MetaKmsPlane *plane) { - switch (meta_kms_plane_get_plane_type (plane)) - { - case META_KMS_PLANE_TYPE_PRIMARY: - return "primary"; - case META_KMS_PLANE_TYPE_CURSOR: - return "cursor"; - case META_KMS_PLANE_TYPE_OVERLAY: - return "overlay"; - } - - g_assert_not_reached (); + return meta_kms_plane_type_to_string (meta_kms_plane_get_plane_type (plane)); } static gboolean diff --git a/src/backends/native/meta-kms-plane.c b/src/backends/native/meta-kms-plane.c index 5b9516adc..d85b9ed06 100644 --- a/src/backends/native/meta-kms-plane.c +++ b/src/backends/native/meta-kms-plane.c @@ -28,6 +28,7 @@ #include "backends/native/meta-kms-impl-device-atomic.h" #include "backends/native/meta-kms-device-private.h" #include "backends/native/meta-kms-update-private.h" +#include "common/meta-drm-format-helpers.h" typedef struct _MetaKmsPlanePropTable { @@ -312,15 +313,23 @@ update_formats (MetaKmsPlane *plane, in_formats = &plane->prop_table.props[META_KMS_PLANE_PROP_IN_FORMATS]; blob_id = in_formats->value; if (blob_id == 0) - return; + { + meta_topic (META_DEBUG_KMS, " Plane has no advertised formats"); + return; + } fd = meta_kms_impl_device_get_fd (impl_device); blob = drmModeGetPropertyBlob (fd, blob_id); if (!blob) - return; + { + g_warning ("Failed to rertieve IN_FORMATS property blob: %s", + g_strerror (errno)); + return; + } if (blob->length < sizeof (struct drm_format_modifier_blob)) { + g_warning ("IN_FORMATS property blob size invalid"); drmModeFreePropertyBlob (blob); return; } @@ -334,6 +343,16 @@ update_formats (MetaKmsPlane *plane, { GArray *modifiers = g_array_new (FALSE, FALSE, sizeof (uint64_t)); + if (meta_is_topic_enabled (META_DEBUG_KMS)) + { + MetaDrmFormatBuf tmp; + + meta_topic (META_DEBUG_KMS, + " Adding format %s (0x%x)", + meta_drm_format_to_string (&tmp, formats[fmt_i]), + formats[fmt_i]); + } + for (mod_i = 0; mod_i < blob_fmt->count_modifiers; mod_i++) { struct drm_format_modifier *drm_modifier = &drm_modifiers[mod_i]; @@ -649,6 +668,11 @@ meta_kms_plane_new (MetaKmsPlaneType type, plane->possible_crtcs = drm_plane->possible_crtcs; plane->device = meta_kms_impl_device_get_device (impl_device); + meta_topic (META_DEBUG_KMS, + "Adding %s plane %u (%s)", + meta_kms_plane_type_to_string (type), + plane->id, + meta_kms_impl_device_get_path (impl_device)); init_properties (plane, impl_device, drm_plane, drm_plane_props); meta_kms_plane_read_state (plane, impl_device, drm_plane, drm_plane_props); @@ -715,3 +739,19 @@ meta_kms_plane_class_init (MetaKmsPlaneClass *klass) object_class->finalize = meta_kms_plane_finalize; } + +const char * +meta_kms_plane_type_to_string (MetaKmsPlaneType plane_type) +{ + switch (plane_type) + { + case META_KMS_PLANE_TYPE_PRIMARY: + return "primary"; + case META_KMS_PLANE_TYPE_CURSOR: + return "cursor"; + case META_KMS_PLANE_TYPE_OVERLAY: + return "overlay"; + } + + g_assert_not_reached (); +} diff --git a/src/backends/native/meta-kms-plane.h b/src/backends/native/meta-kms-plane.h index 3842f4d5f..f79820fdb 100644 --- a/src/backends/native/meta-kms-plane.h +++ b/src/backends/native/meta-kms-plane.h @@ -76,3 +76,5 @@ gboolean meta_kms_plane_is_usable_with (MetaKmsPlane *plane, void meta_kms_plane_update_set_rotation (MetaKmsPlane *plane, MetaKmsPlaneAssignment *plane_assignment, MtkMonitorTransform transform); + +const char * meta_kms_plane_type_to_string (MetaKmsPlaneType plane_type);