drm_hwcomposer: Add method GetOptionalConnectorProperty
Add conveniece method GetOptionalConnectorProperty to reduce boilerplate
/*true=*/ notation.
Change-Id: I888be527dfbecc5c7ccfdd7661e3aeb4a9af04c7
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
diff --git a/drm/DrmConnector.cpp b/drm/DrmConnector.cpp
index eeec3b1..6dbe3c5 100644
--- a/drm/DrmConnector.cpp
+++ b/drm/DrmConnector.cpp
@@ -99,8 +99,7 @@
return false;
}
- if (GetConnectorProperty("Colorspace", &colorspace_property_,
- /*is_optional=*/true)) {
+ if (GetOptionalConnectorProperty("Colorspace", &colorspace_property_)) {
colorspace_property_.AddEnumToMap("Default", Colorspace::kDefault,
colorspace_enum_map_);
colorspace_property_.AddEnumToMap("SMPTE_170M_YCC", Colorspace::kSmpte170MYcc,
@@ -135,11 +134,9 @@
colorspace_enum_map_);
}
- GetConnectorProperty("content type", &content_type_property_,
- /*is_optional=*/true);
+ GetOptionalConnectorProperty("content type", &content_type_property_);
- if (GetConnectorProperty("panel orientation", &panel_orientation_,
- /*is_optional=*/true)) {
+ if (GetOptionalConnectorProperty("panel orientation", &panel_orientation_)) {
panel_orientation_
.AddEnumToMapReverse("Normal",
PanelOrientation::kModePanelOrientationNormal,
@@ -162,9 +159,7 @@
}
int DrmConnector::UpdateEdidProperty() {
- return GetConnectorProperty("EDID", &edid_property_, /*is_optional=*/true)
- ? 0
- : -EINVAL;
+ return GetOptionalConnectorProperty("EDID", &edid_property_) ? 0 : -EINVAL;
}
auto DrmConnector::GetEdidBlob() -> DrmModePropertyBlobUnique {
diff --git a/drm/DrmConnector.h b/drm/DrmConnector.h
index be84ae3..e49cee0 100644
--- a/drm/DrmConnector.h
+++ b/drm/DrmConnector.h
@@ -147,6 +147,10 @@
auto Init() -> bool;
auto GetConnectorProperty(const char *prop_name, DrmProperty *property,
bool is_optional = false) -> bool;
+ auto GetOptionalConnectorProperty(const char *prop_name,
+ DrmProperty *property) -> bool {
+ return GetConnectorProperty(prop_name, property, /*is_optional=*/true);
+ }
const uint32_t index_in_res_array_;