/* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include "HdmiCecPort.h" namespace android { namespace hardware { namespace tv { namespace cec { namespace V1_0 { namespace implementation { using std::shared_ptr; using std::thread; using std::vector; class HdmiCecDefault : public IHdmiCec, public hidl_death_recipient { public: HdmiCecDefault(); ~HdmiCecDefault(); // Methods from ::android::hardware::tv::cec::V1_0::IHdmiCec follow. Return addLogicalAddress(CecLogicalAddress addr) override; Return clearLogicalAddress() override; Return getPhysicalAddress(getPhysicalAddress_cb _hidl_cb) override; Return sendMessage(const CecMessage& message) override; Return setCallback(const sp& callback) override; Return getCecVersion() override; Return getVendorId() override; Return getPortInfo(getPortInfo_cb _hidl_cb) override; Return setOption(OptionKey key, bool value) override; Return setLanguage(const hidl_string& language) override; Return enableAudioReturnChannel(int32_t portId, bool enable) override; Return isConnected(int32_t portId) override; virtual void serviceDied(uint64_t, const wp<::android::hidl::base::V1_0::IBase>&) { setCallback(nullptr); } Return init(); Return release(); private: void event_thread(HdmiCecPort* hdmiCecPort); static int getOpcode(cec_msg message); static int getFirstParam(cec_msg message); static bool isWakeupMessage(cec_msg message); static bool isTransferableInSleep(cec_msg message); static bool isPowerUICommand(cec_msg message); static Return getSendMessageResult(int tx_status); vector mEventThreads; vector> mHdmiCecPorts; // When set to false, all the CEC commands are discarded. True by default after initialization. bool mCecEnabled; /* * When set to false, HAL does not wake up the system upon receiving or * . True by default after initialization. */ bool mWakeupEnabled; /* * Updated when system goes into or comes out of standby mode. * When set to true, Android system is handling CEC commands. * When set to false, microprocessor is handling CEC commands. * True by default after initialization. */ bool mCecControlEnabled; sp mCallback; }; } // namespace implementation } // namespace V1_0 } // namespace cec } // namespace tv } // namespace hardware } // namespace android