Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(771)

Unified Diff: ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc

Issue 1035523004: [6/8][Ozone-Drm] Fix lookup for DRM property values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async-content-protection5
Patch Set: . Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc
diff --git a/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc b/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc
index 9a1d7cc42ccca229e831546f38fb27da59125fbb..477ae7a0f9a8fd460956911f3336c0666c48bfa4 100644
--- a/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc
+++ b/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc
@@ -89,6 +89,23 @@ class FindByDevicePath {
base::FilePath path_;
};
+std::string GetEnumNameForProperty(drmModeConnector* connector,
+ drmModePropertyRes* property) {
+ for (int prop_idx = 0; prop_idx < connector->count_props; ++prop_idx) {
+ if (connector->props[prop_idx] != property->prop_id)
+ continue;
+
+ for (int enum_idx = 0; enum_idx < property->count_enums; ++enum_idx) {
+ const drm_mode_property_enum& property_enum = property->enums[enum_idx];
+ if (property_enum.value == connector->prop_values[prop_idx])
+ return property_enum.name;
+ }
+ }
+
+ NOTREACHED();
+ return std::string();
+}
+
} // namespace
DrmGpuDisplayManager::DrmGpuDisplayManager(
@@ -335,11 +352,8 @@ bool DrmGpuDisplayManager::GetHDCPState(const DrmDisplaySnapshot& output,
return false;
}
- DCHECK_LT(static_cast<int>(hdcp_property->prop_id), connector->count_props);
- int hdcp_state_idx = connector->prop_values[hdcp_property->prop_id];
- DCHECK_LT(hdcp_state_idx, hdcp_property->count_enums);
-
- std::string name(hdcp_property->enums[hdcp_state_idx].name);
+ std::string name =
+ GetEnumNameForProperty(connector.get(), hdcp_property.get());
for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) {
if (name == kContentProtectionStates[i].name) {
*state = kContentProtectionStates[i].state;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698