From cfeeb817bfb62a38a274ffa4b77af86152c3629e Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Mon, 6 Dec 2021 13:17:01 +0100 Subject: [PATCH] backends/drm: query min and max values for properties --- src/backends/drm/drm_property.cpp | 15 +++++++++++++++ src/backends/drm/drm_property.h | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/src/backends/drm/drm_property.cpp b/src/backends/drm/drm_property.cpp index d67704a84d..2848b304a0 100644 --- a/src/backends/drm/drm_property.cpp +++ b/src/backends/drm/drm_property.cpp @@ -30,6 +30,11 @@ DrmProperty::DrmProperty(DrmObject *obj, drmModePropertyRes *prop, uint64_t val, m_enumNames = enumNames; initEnumMap(prop); } + if (prop->flags & DRM_MODE_PROP_RANGE) { + Q_ASSERT(prop->count_values > 1); + m_minValue = prop->values[0]; + m_maxValue = prop->values[1]; + } } DrmProperty::~DrmProperty() = default; @@ -146,4 +151,14 @@ void DrmProperty::setLegacy() m_legacy = true; } +uint64_t DrmProperty::minValue() const +{ + return m_minValue; +} + +uint64_t DrmProperty::maxValue() const +{ + return m_maxValue; +} + } diff --git a/src/backends/drm/drm_property.h b/src/backends/drm/drm_property.h index 67bfe017d5..48bdeafdc2 100644 --- a/src/backends/drm/drm_property.h +++ b/src/backends/drm/drm_property.h @@ -60,6 +60,9 @@ public: void setCurrent(uint64_t value); uint64_t current() const; + uint64_t minValue() const; + uint64_t maxValue() const; + void commit(); void commitPending(); void rollbackPending(); @@ -87,6 +90,9 @@ private: // the value currently set for or by the kernel uint64_t m_current = 0; + uint64_t m_minValue = -1; + uint64_t m_maxValue = -1; + QMap m_enumMap; QVector m_enumNames; const bool m_immutable;