drm_hwcomposer: Add getter/setter for content_type
Optionally, get the content_type drm property. Add implementation to
HwcDisplay::SetContentType to set this property.
Change-Id: I910e064876d13205abc7caaac342daaff8f38599
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
diff --git a/drm/DrmConnector.cpp b/drm/DrmConnector.cpp
index e459fe7..4ae8bef 100644
--- a/drm/DrmConnector.cpp
+++ b/drm/DrmConnector.cpp
@@ -42,22 +42,21 @@
constexpr size_t kTypesCount = 21;
-static bool GetOptionalConnectorProperty(const DrmDevice &dev,
- const DrmConnector &connector,
- const char *prop_name,
- DrmProperty *property) {
- return dev.GetProperty(connector.GetId(), DRM_MODE_OBJECT_CONNECTOR,
- prop_name, property) == 0;
-}
+auto DrmConnector::GetConnectorProperty(const char *prop_name,
+ DrmProperty *property,
+ bool is_optional) -> bool {
+ auto err = drm_->GetProperty(GetId(), DRM_MODE_OBJECT_CONNECTOR, prop_name,
+ property);
+ if (err == 0)
+ return true;
-static bool GetConnectorProperty(const DrmDevice &dev,
- const DrmConnector &connector,
- const char *prop_name, DrmProperty *property) {
- if (!GetOptionalConnectorProperty(dev, connector, prop_name, property)) {
- ALOGE("Could not get %s property\n", prop_name);
- return false;
+ if (is_optional) {
+ ALOGV("Could not get optional %s property from connector %d", prop_name,
+ GetId());
+ } else {
+ ALOGE("Could not get %s property from connector %d", prop_name, GetId());
}
- return true;
+ return false;
}
auto DrmConnector::CreateInstance(DrmDevice &dev, uint32_t connector_id,
@@ -72,28 +71,39 @@
auto c = std::unique_ptr<DrmConnector>(
new DrmConnector(std::move(conn), &dev, index));
- if (!GetConnectorProperty(dev, *c, "DPMS", &c->dpms_property_) ||
- !GetConnectorProperty(dev, *c, "CRTC_ID", &c->crtc_id_property_)) {
- return {};
- }
-
- c->UpdateEdidProperty();
-
- if (c->IsWriteback() &&
- (!GetConnectorProperty(dev, *c, "WRITEBACK_PIXEL_FORMATS",
- &c->writeback_pixel_formats_) ||
- !GetConnectorProperty(dev, *c, "WRITEBACK_FB_ID",
- &c->writeback_fb_id_) ||
- !GetConnectorProperty(dev, *c, "WRITEBACK_OUT_FENCE_PTR",
- &c->writeback_out_fence_))) {
+ if (!c->Init()) {
+ ALOGE("Failed to initialize connector %d", connector_id);
return {};
}
return c;
}
+auto DrmConnector::Init()-> bool {
+ if (!GetConnectorProperty("DPMS", &dpms_property_) ||
+ !GetConnectorProperty("CRTC_ID", &crtc_id_property_)) {
+ return false;
+ }
+
+ UpdateEdidProperty();
+
+ if (IsWriteback() &&
+ (!GetConnectorProperty("WRITEBACK_PIXEL_FORMATS",
+ &writeback_pixel_formats_) ||
+ !GetConnectorProperty("WRITEBACK_FB_ID", &writeback_fb_id_) ||
+ !GetConnectorProperty("WRITEBACK_OUT_FENCE_PTR",
+ &writeback_out_fence_))) {
+ return false;
+ }
+
+ GetConnectorProperty("content type", &content_type_property_,
+ /*is_optional=*/true);
+
+ return true;
+}
+
int DrmConnector::UpdateEdidProperty() {
- return GetOptionalConnectorProperty(*drm_, *this, "EDID", &edid_property_)
+ return GetConnectorProperty("EDID", &edid_property_, /*is_optional=*/true)
? 0
: -EINVAL;
}