| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_display.h" | 5 #include "ui/ozone/platform/drm/gpu/drm_display.h" |
| 6 | 6 |
| 7 #include <xf86drmMode.h> | 7 #include <xf86drmMode.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "ui/display/types/gamma_ramp_rgb_entry.h" | 10 #include "ui/display/types/gamma_ramp_rgb_entry.h" |
| 11 #include "ui/ozone/platform/drm/common/drm_util.h" | 11 #include "ui/ozone/platform/drm/common/drm_util.h" |
| 12 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 12 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
| 13 #include "ui/ozone/platform/drm/gpu/screen_manager.h" | 13 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
| 14 | 14 |
| 15 namespace ui { | 15 namespace ui { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 const char kContentProtection[] = "Content Protection"; | 19 const char kContentProtection[] = "Content Protection"; |
| 20 | 20 |
| 21 struct ContentProtectionMapping { | 21 struct ContentProtectionMapping { |
| 22 const char* name; | 22 const char* name; |
| 23 HDCPState state; | 23 display::HDCPState state; |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 const ContentProtectionMapping kContentProtectionStates[] = { | 26 const ContentProtectionMapping kContentProtectionStates[] = { |
| 27 {"Undesired", HDCP_STATE_UNDESIRED}, | 27 {"Undesired", display::HDCP_STATE_UNDESIRED}, |
| 28 {"Desired", HDCP_STATE_DESIRED}, | 28 {"Desired", display::HDCP_STATE_DESIRED}, |
| 29 {"Enabled", HDCP_STATE_ENABLED}}; | 29 {"Enabled", display::HDCP_STATE_ENABLED}}; |
| 30 | 30 |
| 31 // Converts |state| to the DRM value associated with the it. | 31 // Converts |state| to the DRM value associated with the it. |
| 32 uint32_t GetContentProtectionValue(drmModePropertyRes* property, | 32 uint32_t GetContentProtectionValue(drmModePropertyRes* property, |
| 33 HDCPState state) { | 33 display::HDCPState state) { |
| 34 std::string name; | 34 std::string name; |
| 35 for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) { | 35 for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) { |
| 36 if (kContentProtectionStates[i].state == state) { | 36 if (kContentProtectionStates[i].state == state) { |
| 37 name = kContentProtectionStates[i].name; | 37 name = kContentProtectionStates[i].name; |
| 38 break; | 38 break; |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 for (int i = 0; i < property->count_enums; ++i) | 42 for (int i = 0; i < property->count_enums; ++i) |
| 43 if (name == property->enums[i].name) | 43 if (name == property->enums[i].name) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 VLOG(1) << "Failed to disable device=" << drm_->device_path().value() | 116 VLOG(1) << "Failed to disable device=" << drm_->device_path().value() |
| 117 << " crtc=" << crtc_; | 117 << " crtc=" << crtc_; |
| 118 return false; | 118 return false; |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 origin_ = origin; | 122 origin_ = origin; |
| 123 return true; | 123 return true; |
| 124 } | 124 } |
| 125 | 125 |
| 126 bool DrmDisplay::GetHDCPState(HDCPState* state) { | 126 bool DrmDisplay::GetHDCPState(display::HDCPState* state) { |
| 127 ScopedDrmConnectorPtr connector(drm_->GetConnector(connector_)); | 127 ScopedDrmConnectorPtr connector(drm_->GetConnector(connector_)); |
| 128 if (!connector) { | 128 if (!connector) { |
| 129 PLOG(ERROR) << "Failed to get connector " << connector_; | 129 PLOG(ERROR) << "Failed to get connector " << connector_; |
| 130 return false; | 130 return false; |
| 131 } | 131 } |
| 132 | 132 |
| 133 ScopedDrmPropertyPtr hdcp_property( | 133 ScopedDrmPropertyPtr hdcp_property( |
| 134 drm_->GetProperty(connector.get(), kContentProtection)); | 134 drm_->GetProperty(connector.get(), kContentProtection)); |
| 135 if (!hdcp_property) { | 135 if (!hdcp_property) { |
| 136 PLOG(ERROR) << "'" << kContentProtection << "' property doesn't exist."; | 136 PLOG(ERROR) << "'" << kContentProtection << "' property doesn't exist."; |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 | 139 |
| 140 std::string name = | 140 std::string name = |
| 141 GetEnumNameForProperty(connector.get(), hdcp_property.get()); | 141 GetEnumNameForProperty(connector.get(), hdcp_property.get()); |
| 142 for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) { | 142 for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) { |
| 143 if (name == kContentProtectionStates[i].name) { | 143 if (name == kContentProtectionStates[i].name) { |
| 144 *state = kContentProtectionStates[i].state; | 144 *state = kContentProtectionStates[i].state; |
| 145 VLOG(3) << "HDCP state: " << *state << " (" << name << ")"; | 145 VLOG(3) << "HDCP state: " << *state << " (" << name << ")"; |
| 146 return true; | 146 return true; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 LOG(ERROR) << "Unknown content protection value '" << name << "'"; | 150 LOG(ERROR) << "Unknown content protection value '" << name << "'"; |
| 151 return false; | 151 return false; |
| 152 } | 152 } |
| 153 | 153 |
| 154 bool DrmDisplay::SetHDCPState(HDCPState state) { | 154 bool DrmDisplay::SetHDCPState(display::HDCPState state) { |
| 155 ScopedDrmConnectorPtr connector(drm_->GetConnector(connector_)); | 155 ScopedDrmConnectorPtr connector(drm_->GetConnector(connector_)); |
| 156 if (!connector) { | 156 if (!connector) { |
| 157 PLOG(ERROR) << "Failed to get connector " << connector_; | 157 PLOG(ERROR) << "Failed to get connector " << connector_; |
| 158 return false; | 158 return false; |
| 159 } | 159 } |
| 160 | 160 |
| 161 ScopedDrmPropertyPtr hdcp_property( | 161 ScopedDrmPropertyPtr hdcp_property( |
| 162 drm_->GetProperty(connector.get(), kContentProtection)); | 162 drm_->GetProperty(connector.get(), kContentProtection)); |
| 163 if (!hdcp_property) { | 163 if (!hdcp_property) { |
| 164 LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist."; | 164 LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist."; |
| 165 return false; | 165 return false; |
| 166 } | 166 } |
| 167 | 167 |
| 168 return drm_->SetProperty( | 168 return drm_->SetProperty( |
| 169 connector_, hdcp_property->prop_id, | 169 connector_, hdcp_property->prop_id, |
| 170 GetContentProtectionValue(hdcp_property.get(), state)); | 170 GetContentProtectionValue(hdcp_property.get(), state)); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void DrmDisplay::SetColorCorrection( | 173 void DrmDisplay::SetColorCorrection( |
| 174 const std::vector<GammaRampRGBEntry>& degamma_lut, | 174 const std::vector<display::GammaRampRGBEntry>& degamma_lut, |
| 175 const std::vector<GammaRampRGBEntry>& gamma_lut, | 175 const std::vector<display::GammaRampRGBEntry>& gamma_lut, |
| 176 const std::vector<float>& correction_matrix) { | 176 const std::vector<float>& correction_matrix) { |
| 177 if (!drm_->SetColorCorrection(crtc_, degamma_lut, gamma_lut, | 177 if (!drm_->SetColorCorrection(crtc_, degamma_lut, gamma_lut, |
| 178 correction_matrix)) { | 178 correction_matrix)) { |
| 179 LOG(ERROR) << "Failed to set color correction for display: crtc_id = " | 179 LOG(ERROR) << "Failed to set color correction for display: crtc_id = " |
| 180 << crtc_; | 180 << crtc_; |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace ui | 184 } // namespace ui |
| OLD | NEW |