drm_hwcomposer: Rework DrmProperty class
Simplify code and raise-up clang-tidy level of DrmProperty class
to 'normal'.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/drm/DrmPlane.cpp b/drm/DrmPlane.cpp
index 76a2c6e..4d03840 100644
--- a/drm/DrmPlane.cpp
+++ b/drm/DrmPlane.cpp
@@ -57,21 +57,19 @@
return -ENOTSUP;
}
- int ret = 0;
- uint64_t type = 0;
- std::tie(ret, type) = p.value();
- if (ret != 0) {
+ auto type = p.GetValue();
+ if (!type) {
ALOGE("Failed to get plane type property value");
- return ret;
+ return -EINVAL;
}
- switch (type) {
+ switch (*type) {
case DRM_PLANE_TYPE_OVERLAY:
case DRM_PLANE_TYPE_PRIMARY:
case DRM_PLANE_TYPE_CURSOR:
- type_ = (uint32_t)type;
+ type_ = (uint32_t)*type;
break;
default:
- ALOGE("Invalid plane type %" PRIu64, type);
+ ALOGE("Invalid plane type %" PRIu64, *type);
return -EINVAL;
}
@@ -148,9 +146,10 @@
}
bool DrmPlane::IsCrtcSupported(const DrmCrtc &crtc) const {
- unsigned int crtc_property_value = 0;
- std::tie(std::ignore, crtc_property_value) = crtc_property_.value();
- if (crtc_property_value != 0 && crtc_property_value != crtc.GetId() &&
+ auto crtc_prop_optval = crtc_property_.GetValue();
+ auto crtc_prop_val = crtc_prop_optval ? *crtc_prop_optval : 0;
+
+ if (crtc_prop_val != 0 && crtc_prop_val != crtc.GetId() &&
GetType() == DRM_PLANE_TYPE_PRIMARY) {
// Some DRM driver such as omap_drm allows sharing primary plane between
// CRTCs, but the primay plane could not be shared if it has been used by
@@ -158,10 +157,9 @@
// in the kernel drivers/gpu/drm/drm_atomic.c file.
// The current drm_hwc design is not ready to support such scenario yet,
// so adding the CRTC status check here to workaorund for now.
- ALOGW(
- "%s: This Plane(id=%d) is activated for Crtc(id=%d), could not be used "
- "for Crtc (id=%d)",
- __FUNCTION__, GetId(), crtc_property_value, crtc.GetId());
+ ALOGW("%s: This Plane(id=%d) is activated for Crtc(id=%" PRIu64
+ "), could not be used for Crtc (id=%d)",
+ __FUNCTION__, GetId(), crtc_prop_val, crtc.GetId());
return false;
}
@@ -186,7 +184,7 @@
}
}
- if (alpha_property_.id() == 0 && layer->pi.alpha != UINT16_MAX) {
+ if (!alpha_property_ && layer->pi.alpha != UINT16_MAX) {
ALOGV("Alpha is not supported on plane %d", GetId());
return false;
}
@@ -251,11 +249,11 @@
return -EINVAL;
}
- if (zpos_property_ && !zpos_property_.is_immutable()) {
+ if (zpos_property_ && !zpos_property_.IsImmutable()) {
uint64_t min_zpos = 0;
// Ignore ret and use min_zpos as 0 by default
- std::tie(std::ignore, min_zpos) = zpos_property_.range_min();
+ std::tie(std::ignore, min_zpos) = zpos_property_.RangeMin();
if (!zpos_property_.AtomicSet(pset, zpos + min_zpos)) {
return -EINVAL;