Chromium Code Reviews| Index: ui/ozone/platform/dri/chromeos/native_display_delegate_dri.cc |
| diff --git a/ui/ozone/platform/dri/chromeos/native_display_delegate_dri.cc b/ui/ozone/platform/dri/chromeos/native_display_delegate_dri.cc |
| index 58b5fb264ec9f982a2b7f49af20d9d60ade8f4d7..dd946e9a8296b583c3c5ecaa813c3c8da25b53b0 100644 |
| --- a/ui/ozone/platform/dri/chromeos/native_display_delegate_dri.cc |
| +++ b/ui/ozone/platform/dri/chromeos/native_display_delegate_dri.cc |
| @@ -19,7 +19,36 @@ |
| namespace ui { |
| namespace { |
| + |
| const size_t kMaxDisplayCount = 2; |
| + |
| +const char kContentProtection[] = "Content Protection"; |
| + |
| +struct ContentProtectionMapping { |
| + const char* name; |
| + HDCPState state; |
| +}; |
| + |
| +const ContentProtectionMapping kContentProtectionStates[] = { |
| + {"Undesired", HDCP_STATE_UNDESIRED}, |
| + {"Desired", HDCP_STATE_DESIRED}, |
| + {"Enabled", HDCP_STATE_ENABLED}}; |
| + |
| +uint32_t GetContentProtectionValue(drmModePropertyRes* property, |
| + HDCPState state) { |
| + std::string name; |
| + for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) |
| + if (kContentProtectionStates[i].state == state) |
| + name = kContentProtectionStates[i].name; |
|
alexst (slow to review)
2014/08/26 00:32:04
Once you found a name, you should break.
dnicoara
2014/08/26 00:43:51
Done.
|
| + |
| + for (int i = 0; i < property->count_enums; ++i) |
| + if (name == property->enums[i].name) |
| + return i; |
| + |
| + NOTREACHED(); |
| + return 0; |
| +} |
| + |
| } // namespace |
| NativeDisplayDelegateDri::NativeDisplayDelegateDri( |
| @@ -162,14 +191,63 @@ void NativeDisplayDelegateDri::CreateFrameBuffer(const gfx::Size& size) {} |
| bool NativeDisplayDelegateDri::GetHDCPState(const DisplaySnapshot& output, |
| HDCPState* state) { |
| - NOTIMPLEMENTED(); |
| + const DisplaySnapshotDri& dri_output = |
| + static_cast<const DisplaySnapshotDri&>(output); |
| + |
| + ScopedDrmConnectorPtr connector(dri_->GetConnector(dri_output.connector())); |
| + if (!connector) { |
| + LOG(ERROR) << "Failed to get connector " << dri_output.connector(); |
| + return false; |
| + } |
| + |
| + ScopedDrmPropertyPtr hdcp_property( |
| + dri_->GetProperty(connector.get(), kContentProtection)); |
| + if (!hdcp_property) { |
| + LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist."; |
| + return false; |
| + } |
| + |
| + DCHECK_LT(hdcp_property->prop_id, connector->count_props); |
| + DCHECK_LT(connector->prop_values[hdcp_property->prop_id], |
| + hdcp_property->count_enums); |
| + |
| + std::string name( |
| + hdcp_property->enums[connector->prop_values[hdcp_property->prop_id]] |
|
alexst (slow to review)
2014/08/26 00:32:04
nit: it was a bit hard for me to parse this, maybe
dnicoara
2014/08/26 00:43:51
Done.
|
| + .name); |
| + for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) { |
| + if (name == kContentProtectionStates[i].name) { |
| + *state = kContentProtectionStates[i].state; |
| + VLOG(3) << "HDCP state: " << *state << " (" << name << ")"; |
| + return true; |
| + } |
| + } |
| + |
| + LOG(ERROR) << "Unknown content protection value '" << name << "'"; |
| return false; |
| } |
| bool NativeDisplayDelegateDri::SetHDCPState(const DisplaySnapshot& output, |
| HDCPState state) { |
| - NOTIMPLEMENTED(); |
| - return false; |
| + const DisplaySnapshotDri& dri_output = |
| + static_cast<const DisplaySnapshotDri&>(output); |
| + |
| + ScopedDrmConnectorPtr connector(dri_->GetConnector(dri_output.connector())); |
| + if (!connector) { |
| + LOG(ERROR) << "Failed to get connector " << dri_output.connector(); |
| + return false; |
| + } |
| + |
| + ScopedDrmPropertyPtr hdcp_property( |
| + dri_->GetProperty(connector.get(), kContentProtection)); |
| + if (!hdcp_property) { |
| + LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist."; |
| + return false; |
| + } |
| + |
| + return dri_->SetProperty( |
| + dri_output.connector(), |
| + hdcp_property->prop_id, |
| + GetContentProtectionValue(hdcp_property.get(), state)); |
| } |
| std::vector<ui::ColorCalibrationProfile> |