1 /* 2 // Copyright (c) 2014 Intel Corporation 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 */ 16 #ifndef HDCP_CONTROL_H 17 #define HDCP_CONTROL_H 18 19 #include <IHdcpControl.h> 20 #include <common/base/SimpleThread.h> 21 22 namespace android { 23 namespace intel { 24 25 class HdcpControl : public IHdcpControl { 26 public: 27 HdcpControl(); 28 virtual ~HdcpControl(); 29 30 public: 31 virtual bool startHdcp(); 32 virtual bool startHdcpAsync(HdcpStatusCallback cb, void *userData); 33 virtual bool stopHdcp(); 34 35 protected: 36 bool enableAuthentication(); 37 bool disableAuthentication(); 38 bool enableOverlay(); 39 bool disableOverlay(); 40 bool enableDisplayIED(); 41 bool disableDisplayIED(); 42 bool isHdcpSupported(); 43 bool checkAuthenticated(); 44 virtual bool preRunHdcp(); 45 virtual bool postRunHdcp(); 46 bool runHdcp(); 47 inline void signalCompletion(); 48 49 private: 50 enum { 51 HDCP_INLOOP_RETRY_NUMBER = 1, 52 HDCP_INLOOP_RETRY_DELAY_US = 50000, 53 HDCP_VERIFICATION_DELAY_MS = 2000, 54 HDCP_ASYNC_START_DELAY_MS = 100, 55 HDCP_AUTHENTICATION_SHORT_DELAY_MS = 200, 56 HDCP_AUTHENTICATION_LONG_DELAY_MS = 2000, 57 HDCP_AUTHENTICATION_TIMEOUT_MS = 5000, 58 HDCP_RETRY_LIMIT = 10, 59 }; 60 61 enum { 62 CALLBACK_PENDING, 63 CALLBACK_AUTHENTICATED, 64 CALLBACK_NOT_AUTHENTICATED, 65 }; 66 67 protected: 68 HdcpStatusCallback mCallback; 69 void *mUserData; 70 int mCallbackState; 71 Mutex mMutex; 72 Condition mStoppedCondition; 73 Condition mCompletedCondition; 74 bool mWaitForCompletion; 75 bool mStopped; 76 bool mAuthenticated; 77 int mActionDelay; // in milliseconds 78 uint32_t mAuthRetryCount; 79 bool mEnableAuthenticationLog; 80 81 private: 82 DECLARE_THREAD(HdcpControlThread, HdcpControl); 83 }; 84 85 } // namespace intel 86 } // namespace android 87 88 #endif /* HDCP_CONTROL_H */ 89