From 1e572a42992d55df1baf5a084cd27ed4c51e8f17 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Sun, 22 Aug 2021 22:25:03 +0200 Subject: [PATCH] platforms/drm: make debug logging less verbose --- src/plugins/platforms/drm/drm_object.cpp | 56 +++++++++++-------- src/plugins/platforms/drm/drm_object.h | 14 ++--- .../platforms/drm/drm_object_connector.cpp | 1 - src/plugins/platforms/drm/drm_object_crtc.cpp | 1 - .../platforms/drm/drm_object_plane.cpp | 3 +- src/plugins/platforms/drm/egl_gbm_backend.cpp | 16 ++---- 6 files changed, 43 insertions(+), 48 deletions(-) diff --git a/src/plugins/platforms/drm/drm_object.cpp b/src/plugins/platforms/drm/drm_object.cpp index 8f09ef4277..78939e15b3 100644 --- a/src/plugins/platforms/drm/drm_object.cpp +++ b/src/plugins/platforms/drm/drm_object.cpp @@ -41,9 +41,39 @@ bool DrmObject::initProps() return false; } if (KWIN_DRM().isDebugEnabled() && m_gpu->atomicModeSetting()) { - for (int i = 0; i < m_propertyDefinitions.count(); i++) { - if (!m_props[i]) { - qCDebug(KWIN_DRM) << "Could not find property" << m_propertyDefinitions[i].name; + auto debug = QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, KWIN_DRM().categoryName()).debug().nospace(); + switch(m_objectType) { + case DRM_MODE_OBJECT_CONNECTOR: + debug << "Connector "; + break; + case DRM_MODE_OBJECT_CRTC: + debug << "Crtc "; + break; + case DRM_MODE_OBJECT_PLANE: + debug << "Plane "; + break; + default: + Q_UNREACHABLE(); + } + debug << m_id << " has properties "; + for (int i = 0; i < m_props.count(); i++) { + if (i > 0) { + debug << ", "; + } + const auto &prop = m_props[i]; + if (prop) { + debug << prop->name() << "="; + if (m_propertyDefinitions[i].enumNames.isEmpty()) { + debug << prop->current(); + } else { + if (prop->current() < static_cast(prop->enumMap().count())) { + debug << prop->enumNames()[prop->enumMap()[prop->current()]]; + } else { + debug << "invalid value: " << prop->current(); + } + } + } else { + debug << m_propertyDefinitions[i].name << " not found"; } } } @@ -134,7 +164,6 @@ bool DrmObject::updateProperties() m_props[propIndex]->setCurrent(properties->prop_values[drmPropIndex]); } } else { - qCDebug(KWIN_DRM, "Found property %s with value %lu", def.name.data(), properties->prop_values[drmPropIndex]); m_props[propIndex] = new Property(m_gpu, prop.data(), properties->prop_values[drmPropIndex], def.enumNames, blob); } found = true; @@ -165,7 +194,6 @@ DrmObject::Property::Property(DrmGpu *gpu, drmModePropertyRes *prop, uint64_t va , m_gpu(gpu) { if (!enumNames.isEmpty()) { - qCDebug(KWIN_DRM) << m_propName << " can have enums:" << enumNames; m_enumNames = enumNames; initEnumMap(prop); } @@ -300,9 +328,6 @@ void DrmObject::Property::initEnumMap(drmModePropertyRes *prop) const int nameCount = m_enumNames.size(); m_enumMap.resize(nameCount); - qCDebug(KWIN_DRM).nospace() << "Available are " << prop->count_enums << - " enums. Query their runtime values:"; - for (int i = 0; i < prop->count_enums; i++) { struct drm_mode_property_enum *en = &prop->enums[i]; int j = 0; @@ -317,24 +342,9 @@ void DrmObject::Property::initEnumMap(drmModePropertyRes *prop) } if (j < nameCount) { - qCDebug(KWIN_DRM).nospace() << "Enum '" << en->name - << "': runtime-value = " << en->value; m_enumMap[j] = en->value; } } - - if (KWIN_DRM().isDebugEnabled()) { - for (int i = 0; i < m_enumMap.size(); i++) { - if (m_current == m_enumMap[i]) { - // TODO: This does not work with bitmask properties, because from kernel we get the - // values for some reason as the shift distance instead of the full value. - // See: https://github.com/torvalds/linux/blob/6794862a/drivers/ - // gpu/drm/drm_blend.c#L267 - qCDebug(KWIN_DRM) << "=>" << m_propName - << "with mapped enum value" << m_enumNames[i]; - } - } - } } } diff --git a/src/plugins/platforms/drm/drm_object.h b/src/plugins/platforms/drm/drm_object.h index 9ead3af331..9f3f379422 100644 --- a/src/plugins/platforms/drm/drm_object.h +++ b/src/plugins/platforms/drm/drm_object.h @@ -83,15 +83,11 @@ public: void initEnumMap(drmModePropertyRes *prop); - /** - * For properties of enum type the enum map identifies the kernel runtime values, - * which must be queried beforehand. - * - * @param n the index to the enum - * @return the runtime enum value corresponding with enum index @param n - */ - uint64_t enumMap(int n) const { - return m_enumMap[n]; // TODO: test on index out of bounds? + QVector enumNames() const { + return m_enumNames; + } + QVector enumMap() const { + return m_enumMap; } bool hasEnum(uint64_t value) const { return m_enumMap.contains(value); diff --git a/src/plugins/platforms/drm/drm_object_connector.cpp b/src/plugins/platforms/drm/drm_object_connector.cpp index acbfb45a14..949914fa44 100644 --- a/src/plugins/platforms/drm/drm_object_connector.cpp +++ b/src/plugins/platforms/drm/drm_object_connector.cpp @@ -74,7 +74,6 @@ bool DrmConnector::init() if (!m_conn || !m_conn->count_modes) { return false; } - qCDebug(KWIN_DRM) << "Creating connector" << id(); if (!initProps()) { return false; diff --git a/src/plugins/platforms/drm/drm_object_crtc.cpp b/src/plugins/platforms/drm/drm_object_crtc.cpp index 32ffe967d2..f810c04455 100644 --- a/src/plugins/platforms/drm/drm_object_crtc.cpp +++ b/src/plugins/platforms/drm/drm_object_crtc.cpp @@ -34,7 +34,6 @@ bool DrmCrtc::init() if (!m_crtc) { return false; } - qCDebug(KWIN_DRM) << "Init for CRTC:" << pipeIndex() << "id:" << id(); return initProps(); } diff --git a/src/plugins/platforms/drm/drm_object_plane.cpp b/src/plugins/platforms/drm/drm_object_plane.cpp index a082f812bf..19596d2764 100644 --- a/src/plugins/platforms/drm/drm_object_plane.cpp +++ b/src/plugins/platforms/drm/drm_object_plane.cpp @@ -50,7 +50,6 @@ DrmPlane::DrmPlane(DrmGpu *gpu, uint32_t planeId) bool DrmPlane::init() { - qCDebug(KWIN_DRM) << "Atomic init for plane:" << id(); DrmScopedPointer p(drmModeGetPlane(gpu()->fd(), id())); if (!p) { @@ -121,7 +120,7 @@ DrmPlane::TypeIndex DrmPlane::type() return TypeIndex::Overlay; } for (uint32_t i = 0; i < static_cast(TypeIndex::Count); i++) { - if (property->enumMap(i) == property->current()) { + if (property->enumMap()[i] == property->current()) { return TypeIndex(i); } } diff --git a/src/plugins/platforms/drm/egl_gbm_backend.cpp b/src/plugins/platforms/drm/egl_gbm_backend.cpp index e3f9a22548..2c978029dc 100644 --- a/src/plugins/platforms/drm/egl_gbm_backend.cpp +++ b/src/plugins/platforms/drm/egl_gbm_backend.cpp @@ -409,6 +409,10 @@ bool EglGbmBackend::initBufferConfigs() // Query some configuration parameters, to show in debug log. eglGetConfigAttrib(eglDisplay(), configs[i], EGL_NATIVE_VISUAL_ID, &gbmFormat); + if (!m_gpu->isFormatSupported(gbmFormat)) { + continue; + } + // Query number of bits for color channel EGLint blueSize, redSize, greenSize, alphaSize; eglGetConfigAttrib(eglDisplay(), configs[i], EGL_RED_SIZE, &redSize); @@ -416,18 +420,6 @@ bool EglGbmBackend::initBufferConfigs() eglGetConfigAttrib(eglDisplay(), configs[i], EGL_BLUE_SIZE, &blueSize); eglGetConfigAttrib(eglDisplay(), configs[i], EGL_ALPHA_SIZE, &alphaSize); - if (KWIN_DRM().isDebugEnabled()) { - // GBM formats are declared as FOURCC code (integer from ASCII chars, so use this fact). - char gbmFormatStr[sizeof(EGLint) + 1] = {0}; - memcpy(gbmFormatStr, &gbmFormat, sizeof(EGLint)); - qCDebug(KWIN_DRM) << " EGL config #" << i << " has GBM FOURCC format:" << gbmFormatStr - << "; color sizes (RGBA order):" - << redSize << greenSize << blueSize << alphaSize; - } - - if (!m_gpu->isFormatSupported(gbmFormat)) { - continue; - } // prefer XRGB8888 as it's most likely to be supported by secondary GPUs as well if (gbmFormat == GBM_BO_FORMAT_XRGB8888) { m_gbmFormat = gbmFormat;