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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" 5 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_descriptor_posix.h" 9 #include "base/file_descriptor_posix.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 explicit FindByDevicePath(const base::FilePath& path) : path_(path) {} 82 explicit FindByDevicePath(const base::FilePath& path) : path_(path) {}
83 83
84 bool operator()(const scoped_refptr<DrmDevice>& device) { 84 bool operator()(const scoped_refptr<DrmDevice>& device) {
85 return device->device_path() == path_; 85 return device->device_path() == path_;
86 } 86 }
87 87
88 private: 88 private:
89 base::FilePath path_; 89 base::FilePath path_;
90 }; 90 };
91 91
92 std::string GetEnumNameForProperty(drmModeConnector* connector,
93 drmModePropertyRes* property) {
94 for (int prop_idx = 0; prop_idx < connector->count_props; ++prop_idx) {
95 if (connector->props[prop_idx] != property->prop_id)
96 continue;
97
98 for (int enum_idx = 0; enum_idx < property->count_enums; ++enum_idx) {
99 const drm_mode_property_enum& property_enum = property->enums[enum_idx];
100 if (property_enum.value == connector->prop_values[prop_idx])
101 return property_enum.name;
102 }
103 }
104
105 NOTREACHED();
106 return std::string();
107 }
108
92 } // namespace 109 } // namespace
93 110
94 DrmGpuDisplayManager::DrmGpuDisplayManager( 111 DrmGpuDisplayManager::DrmGpuDisplayManager(
95 ScreenManager* screen_manager, 112 ScreenManager* screen_manager,
96 const scoped_refptr<DrmDevice>& primary_device, 113 const scoped_refptr<DrmDevice>& primary_device,
97 scoped_ptr<DrmDeviceGenerator> drm_device_generator) 114 scoped_ptr<DrmDeviceGenerator> drm_device_generator)
98 : screen_manager_(screen_manager), 115 : screen_manager_(screen_manager),
99 drm_device_generator_(drm_device_generator.Pass()) { 116 drm_device_generator_(drm_device_generator.Pass()) {
100 devices_.push_back(primary_device); 117 devices_.push_back(primary_device);
101 } 118 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 return false; 345 return false;
329 } 346 }
330 347
331 ScopedDrmPropertyPtr hdcp_property( 348 ScopedDrmPropertyPtr hdcp_property(
332 output.drm()->GetProperty(connector.get(), kContentProtection)); 349 output.drm()->GetProperty(connector.get(), kContentProtection));
333 if (!hdcp_property) { 350 if (!hdcp_property) {
334 PLOG(ERROR) << "'" << kContentProtection << "' property doesn't exist."; 351 PLOG(ERROR) << "'" << kContentProtection << "' property doesn't exist.";
335 return false; 352 return false;
336 } 353 }
337 354
338 DCHECK_LT(static_cast<int>(hdcp_property->prop_id), connector->count_props); 355 std::string name =
339 int hdcp_state_idx = connector->prop_values[hdcp_property->prop_id]; 356 GetEnumNameForProperty(connector.get(), hdcp_property.get());
340 DCHECK_LT(hdcp_state_idx, hdcp_property->count_enums);
341
342 std::string name(hdcp_property->enums[hdcp_state_idx].name);
343 for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) { 357 for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) {
344 if (name == kContentProtectionStates[i].name) { 358 if (name == kContentProtectionStates[i].name) {
345 *state = kContentProtectionStates[i].state; 359 *state = kContentProtectionStates[i].state;
346 VLOG(3) << "HDCP state: " << *state << " (" << name << ")"; 360 VLOG(3) << "HDCP state: " << *state << " (" << name << ")";
347 return true; 361 return true;
348 } 362 }
349 } 363 }
350 364
351 LOG(ERROR) << "Unknown content protection value '" << name << "'"; 365 LOG(ERROR) << "Unknown content protection value '" << name << "'";
352 return false; 366 return false;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 408
395 if (it == old_displays.end()) { 409 if (it == old_displays.end()) {
396 screen_manager_->AddDisplayController(new_displays[i]->drm(), 410 screen_manager_->AddDisplayController(new_displays[i]->drm(),
397 new_displays[i]->crtc(), 411 new_displays[i]->crtc(),
398 new_displays[i]->connector()); 412 new_displays[i]->connector());
399 } 413 }
400 } 414 }
401 } 415 }
402 416
403 } // namespace ui 417 } // namespace ui
OLDNEW
« 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