Commit 7bf0d74a authored by kcwu's avatar kcwu Committed by Commit bot

Don't enable HDCP again if it is active

BUG=412841

Review URL: https://codereview.chromium.org/584533002

Cr-Commit-Position: refs/heads/master@{#296421}
parent c496fa8a
...@@ -251,12 +251,22 @@ bool DisplayConfigurator::ApplyProtections(const ContentProtections& requests) { ...@@ -251,12 +251,22 @@ bool DisplayConfigurator::ApplyProtections(const ContentProtections& requests) {
case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: case DISPLAY_CONNECTION_TYPE_DISPLAYPORT:
case DISPLAY_CONNECTION_TYPE_DVI: case DISPLAY_CONNECTION_TYPE_DVI:
case DISPLAY_CONNECTION_TYPE_HDMI: { case DISPLAY_CONNECTION_TYPE_HDMI: {
HDCPState new_desired_state = HDCPState current_state;
(all_desired & CONTENT_PROTECTION_METHOD_HDCP) ? // Need to poll the driver for updates since other applications may
HDCP_STATE_DESIRED : HDCP_STATE_UNDESIRED; // have updated the state.
if (!native_display_delegate_->SetHDCPState(*it->display, if (!native_display_delegate_->GetHDCPState(*it->display,
new_desired_state)) &current_state))
return false; return false;
bool current_desired = (current_state != HDCP_STATE_UNDESIRED);
bool new_desired = (all_desired & CONTENT_PROTECTION_METHOD_HDCP);
// Don't enable again if HDCP is already active. Some buggy drivers
// may disable and enable if setting "desired" in active state.
if (current_desired != new_desired) {
HDCPState new_state =
new_desired ? HDCP_STATE_DESIRED : HDCP_STATE_UNDESIRED;
if (!native_display_delegate_->SetHDCPState(*it->display, new_state))
return false;
}
break; break;
} }
case DISPLAY_CONNECTION_TYPE_INTERNAL: case DISPLAY_CONNECTION_TYPE_INTERNAL:
......
...@@ -1177,14 +1177,43 @@ TEST_F(DisplayConfiguratorTest, ContentProtectionTwoClients) { ...@@ -1177,14 +1177,43 @@ TEST_F(DisplayConfiguratorTest, ContentProtectionTwoClients) {
// Protections will be disabled only if no more clients request them. // Protections will be disabled only if no more clients request them.
EXPECT_TRUE(configurator_.EnableContentProtection( EXPECT_TRUE(configurator_.EnableContentProtection(
client2, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_NONE)); client2, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_NONE));
EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_DESIRED).c_str(), EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
log_->GetActionsAndClear());
EXPECT_TRUE(configurator_.EnableContentProtection( EXPECT_TRUE(configurator_.EnableContentProtection(
client1, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_NONE)); client1, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_NONE));
EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_UNDESIRED).c_str(), EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_UNDESIRED).c_str(),
log_->GetActionsAndClear()); log_->GetActionsAndClear());
} }
TEST_F(DisplayConfiguratorTest, ContentProtectionTwoClientsEnable) {
DisplayConfigurator::ContentProtectionClientId client1 =
configurator_.RegisterContentProtectionClient();
DisplayConfigurator::ContentProtectionClientId client2 =
configurator_.RegisterContentProtectionClient();
EXPECT_NE(client1, client2);
configurator_.Init(false);
configurator_.ForceInitialConfigure(0);
UpdateOutputs(2, true);
log_->GetActionsAndClear();
// Only enable once if HDCP is enabling.
EXPECT_TRUE(configurator_.EnableContentProtection(
client1, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_HDCP));
native_display_delegate_->set_hdcp_state(HDCP_STATE_DESIRED);
EXPECT_TRUE(configurator_.EnableContentProtection(
client2, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_HDCP));
EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_DESIRED).c_str(),
log_->GetActionsAndClear());
native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED);
// Don't enable again if HDCP is already active.
EXPECT_TRUE(configurator_.EnableContentProtection(
client1, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_HDCP));
EXPECT_TRUE(configurator_.EnableContentProtection(
client2, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_HDCP));
EXPECT_EQ(kNoActions, log_->GetActionsAndClear());
}
TEST_F(DisplayConfiguratorTest, HandleConfigureCrtcFailure) { TEST_F(DisplayConfiguratorTest, HandleConfigureCrtcFailure) {
InitWithSingleOutput(); InitWithSingleOutput();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment