drm_hwcomposer: Set zpos relative to the minimum possible value
Current implementation doesn't handle properly the cases where zpos
range starts from 1.
See https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/issues/19#note_100622
Fixes: ea1c5e5a ("drm_hwcomposer: Add z order support")
Signed-off-by: Alexandru Gheorghe <alexc.g1.ro@gmail.com>
[seanpaul converted to std::tuple return type]
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I35dc2c1cfd0e38ca3a47cf4e668eeb5f3c470ddb
diff --git a/drmproperty.cpp b/drmproperty.cpp
index e276f56..3aeed13 100644
--- a/drmproperty.cpp
+++ b/drmproperty.cpp
@@ -99,6 +99,28 @@
return id_ && (flags_ & DRM_MODE_PROP_IMMUTABLE);
}
+bool DrmProperty::is_range() const {
+ return id_ && (flags_ & DRM_MODE_PROP_RANGE);
+}
+
+std::tuple<int, uint64_t> DrmProperty::range_min() const {
+ if (!is_range())
+ return std::make_tuple(-EINVAL, 0);
+ if (values_.size() < 1)
+ return std::make_tuple(-ENOENT, 0);
+
+ return std::make_tuple(0, values_[0]);
+}
+
+std::tuple<int, uint64_t> DrmProperty::range_max() const {
+ if (!is_range())
+ return std::make_tuple(-EINVAL, 0);
+ if (values_.size() < 2)
+ return std::make_tuple(-ENOENT, 0);
+
+ return std::make_tuple(0, values_[1]);
+}
+
std::tuple<uint64_t, int> DrmProperty::GetEnumValueWithName(
std::string name) const {
for (auto it : enums_) {