@@ -46,23 +46,36 @@ DisplayModeController::Display::Display(DisplaySnapshotRef snapshot,
4646 renderRateFpsTrace(concatId(" RenderRateFps" )),
4747 hasDesiredModeTrace(concatId(" HasDesiredMode" ), false) {}
4848
49+ DisplayModeController::DisplayModeController () {
50+ using namespace std ::string_literals;
51+ mSupportsHdcp = base::GetBoolProperty (" debug.sf.hdcp_support" s, false );
52+ }
53+
4954void DisplayModeController::registerDisplay (PhysicalDisplayId displayId,
5055 DisplaySnapshotRef snapshotRef,
5156 RefreshRateSelectorPtr selectorPtr) {
57+ DisplayPtr displayPtr = std::make_unique<Display>(snapshotRef, selectorPtr);
58+ // TODO: b/349703362 - Remove first condition when HDCP aidl APIs are enforced
59+ displayPtr->setSecure (!supportsHdcp () ||
60+ snapshotRef.get ().connectionType () ==
61+ ui::DisplayConnectionType::Internal);
5262 std::lock_guard lock (mDisplayLock );
53- mDisplays .emplace_or_replace (displayId, std::make_unique<Display>(snapshotRef, selectorPtr ));
63+ mDisplays .emplace_or_replace (displayId, std::move (displayPtr ));
5464}
5565
5666void DisplayModeController::registerDisplay (DisplaySnapshotRef snapshotRef,
5767 DisplayModeId activeModeId,
5868 scheduler::RefreshRateSelector::Config config) {
5969 const auto & snapshot = snapshotRef.get ();
6070 const auto displayId = snapshot.displayId ();
61-
71+ DisplayPtr displayPtr =
72+ std::make_unique<Display>(snapshotRef, snapshot.displayModes (), activeModeId, config);
73+ // TODO: b/349703362 - Remove first condition when HDCP aidl APIs are enforced
74+ displayPtr->setSecure (!supportsHdcp () ||
75+ snapshotRef.get ().connectionType () ==
76+ ui::DisplayConnectionType::Internal);
6277 std::lock_guard lock (mDisplayLock );
63- mDisplays .emplace_or_replace (displayId,
64- std::make_unique<Display>(snapshotRef, snapshot.displayModes (),
65- activeModeId, config));
78+ mDisplays .emplace_or_replace (displayId, std::move (displayPtr));
6679}
6780
6881void DisplayModeController::unregisterDisplay (PhysicalDisplayId displayId) {
@@ -304,5 +317,30 @@ auto DisplayModeController::getKernelIdleTimerState(PhysicalDisplayId displayId)
304317 return {desiredModeIdOpt, displayPtr->isKernelIdleTimerEnabled };
305318}
306319
320+ bool DisplayModeController::supportsHdcp () const {
321+ return mSupportsHdcp && FlagManager::getInstance ().hdcp_level_hal () &&
322+ FlagManager::getInstance ().hdcp_negotiation ();
323+ }
324+
325+ void DisplayModeController::startHdcpNegotiation (PhysicalDisplayId displayId) {
326+ using aidl::android::hardware::drm::HdcpLevel;
327+ using aidl::android::hardware::drm::HdcpLevels;
328+ constexpr HdcpLevels kLevels = {.connectedLevel = HdcpLevel::HDCP_V2_1,
329+ .maxLevel = HdcpLevel::HDCP_V2_3};
330+
331+ std::lock_guard lock (mDisplayLock );
332+ const auto & displayPtr = FTL_TRY (mDisplays .get (displayId).ok_or (ftl::Unit ())).get ();
333+ if (displayPtr->hdcpState == HdcpState::Desired) {
334+ const auto status = mComposerPtr ->startHdcpNegotiation (displayId, kLevels );
335+ displayPtr->hdcpState = (status == NO_ERROR) ? HdcpState::Enabled : HdcpState::Undesired;
336+ }
337+ }
338+
339+ void DisplayModeController::setSecure (PhysicalDisplayId displayId, bool secure) {
340+ std::lock_guard lock (mDisplayLock );
341+ const auto & displayPtr = FTL_TRY (mDisplays .get (displayId).ok_or (ftl::Unit ())).get ();
342+ displayPtr->setSecure (secure);
343+ }
344+
307345#pragma clang diagnostic pop
308346} // namespace android::display
0 commit comments