@@ -675,4 +675,84 @@ auto DrmAtomicStateManager::SetColorBrightnessContrast(void) ->int{
675675
676676 return 0 ;
677677}
678+
679+ void DrmAtomicStateManager::SetHDCPState (HWCContentProtection state,
680+ HWCContentType content_type) {
681+ uint64_t value = 3 ;
682+ uint64_t type = 3 ;
683+ int ret =0 ;
684+
685+ auto *connector = pipe_->connector ->Get ();
686+
687+ if (!connector->IsConnected ())
688+ return ;
689+
690+ desired_protection_support_ = state;
691+ ALOGD (" SetHDCPState desired_protection_support_ %d\n " ,desired_protection_support_);
692+ ALOGD (" SetHDCPState current_protection_support_ %d\n " ,current_protection_support_);
693+
694+ if (desired_protection_support_ == current_protection_support_)
695+ return ;
696+
697+ if (pipe_->connector ->Get ()->GetHdcpTypeProperty ().id () <= 0 ) {
698+ ALOGE (" Cannot set HDCP state as Type property is not supported \n " );
699+ return ;
700+ }
701+
702+ std::tie (ret, type) = pipe_->connector ->Get ()->GetHdcpTypeProperty ().value ();
703+ ALOGD (" Get Content type %lu \n " , type);
704+ ALOGD (" Get Content content_type %u \n " , content_type);
705+
706+ if ((content_type < 2 ) && (content_type_ != content_type)) {
707+ content_type_ = content_type;
708+
709+ ALOGD (" Set Content type %u \n " , content_type);
710+ drmModeConnectorSetProperty (pipe_->device ->GetFd (),
711+ pipe_->connector ->Get ()->GetId (),
712+ pipe_->connector ->Get ()->GetHdcpTypeProperty ().id (),
713+ content_type);
714+
715+ }
716+
717+ if (pipe_->connector ->Get ()->GetHdcpProperty ().id () <= 0 ) {
718+ ALOGE (" Cannot set HDCP state as Connector property is not supported \n " );
719+ return ;
720+ }
721+
722+ std::tie (ret, value) = pipe_->connector ->Get ()->GetHdcpProperty ().value ();
723+ ALOGD (" Get Content Protection value %lu \n " , value);
724+
725+ if (value < 3 ) {
726+ switch (value) {
727+ case 0 :
728+ // current_protection_support_ = HWCContentProtection::kUnDesired;
729+ current_protection_support_ = hwcomposer::HWCContentProtection::kUnDesired ;
730+ ALOGD (" %s GetHDCPConnectorProperty value 0" , __FUNCTION__);
731+ break ;
732+ case 1 :
733+ // current_protection_support_ = HWCContentProtection::kDesired;
734+ current_protection_support_ = hwcomposer::HWCContentProtection::kDesired ;
735+ ALOGD (" %s GetHDCPConnectorProperty value 1" , __FUNCTION__);
736+ break ;
737+ default :
738+ ALOGE (" %s GetHDCPConnectorProperty default" , __FUNCTION__);
739+ break ;
740+ }
741+ }
742+
743+ if (desired_protection_support_ == HWCContentProtection::kUnSupported ) {
744+ desired_protection_support_ = current_protection_support_;
745+ }
746+
747+ current_protection_support_ = desired_protection_support_;
748+ if (current_protection_support_ == kDesired ) {
749+ value = 1 ;
750+ }
751+
752+ ALOGD (" Set Content Protection %lu \n " , value);
753+ drmModeConnectorSetProperty (pipe_->device ->GetFd (),
754+ pipe_->connector ->Get ()->GetId (),
755+ pipe_->connector ->Get ()->GetHdcpProperty ().id (),
756+ value);
757+ }
678758} // namespace android
0 commit comments