blob: b2f1113e8a90525241e34ff5c18fa67e337ba9c4 [file] [log] [blame]
Amye4ddc0d2019-06-13 19:21:24 -07001/*
2 * Copyright (C) 2019 The Android Open Source Project
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
17#ifndef ANDROID_HARDWARE_TV_CEC_V1_0_HDMICEC_H
18#define ANDROID_HARDWARE_TV_CEC_V1_0_HDMICEC_H
19
20#include <android/hardware/tv/cec/1.0/IHdmiCec.h>
21#include <hardware/hardware.h>
22#include <hardware/hdmi_cec.h>
23#include <hidl/MQDescriptor.h>
24#include <hidl/Status.h>
25#include <algorithm>
26#include <vector>
27
28using namespace std;
29
30namespace android {
31namespace hardware {
32namespace tv {
33namespace cec {
34namespace V1_0 {
35namespace implementation {
36
37using ::android::sp;
38using ::android::hardware::hidl_string;
39using ::android::hardware::hidl_vec;
40using ::android::hardware::Return;
41using ::android::hardware::Void;
42using ::android::hardware::tv::cec::V1_0::CecLogicalAddress;
43using ::android::hardware::tv::cec::V1_0::CecMessage;
44using ::android::hardware::tv::cec::V1_0::HdmiPortInfo;
45using ::android::hardware::tv::cec::V1_0::IHdmiCec;
46using ::android::hardware::tv::cec::V1_0::IHdmiCecCallback;
47using ::android::hardware::tv::cec::V1_0::MaxLength;
48using ::android::hardware::tv::cec::V1_0::OptionKey;
49using ::android::hardware::tv::cec::V1_0::Result;
50using ::android::hardware::tv::cec::V1_0::SendMessageResult;
51
52struct HdmiCecMock : public IHdmiCec, public hidl_death_recipient {
53 HdmiCecMock();
54 // Methods from ::android::hardware::tv::cec::V1_0::IHdmiCec follow.
55 Return<Result> addLogicalAddress(CecLogicalAddress addr) override;
56 Return<void> clearLogicalAddress() override;
57 Return<void> getPhysicalAddress(getPhysicalAddress_cb _hidl_cb) override;
58 Return<SendMessageResult> sendMessage(const CecMessage& message) override;
59 Return<void> setCallback(const sp<IHdmiCecCallback>& callback) override;
60 Return<int32_t> getCecVersion() override;
61 Return<uint32_t> getVendorId() override;
62 Return<void> getPortInfo(getPortInfo_cb _hidl_cb) override;
63 Return<void> setOption(OptionKey key, bool value) override;
64 Return<void> setLanguage(const hidl_string& language) override;
65 Return<void> enableAudioReturnChannel(int32_t portId, bool enable) override;
66 Return<bool> isConnected(int32_t portId) override;
67
68 virtual void serviceDied(uint64_t /*cookie*/,
69 const wp<::android::hidl::base::V1_0::IBase>& /*who*/) {
70 setCallback(nullptr);
71 }
72
73 void cec_set_option(int flag, int value);
74
75 private:
76 sp<IHdmiCecCallback> mCallback;
77 // Variables for the virtual cec hal impl
78 uint16_t mPhysicalAddress = 0xFFFF;
79 vector<CecLogicalAddress> mLogicalAddresses;
80 int32_t mCecVersion = 0;
81 uint32_t mCecVendorId = 0;
82 // Port configuration
83 int mTotalPorts = 4;
84 // CEC Option value
85 int mOptionWakeUp = 0;
86 int mOptionEnableCec = 0;
87 int mOptionSystemCecControl = 0;
88 int mOptionLanguage = 0;
89};
90} // namespace implementation
91} // namespace V1_0
92} // namespace cec
93} // namespace tv
94} // namespace hardware
95} // namespace android
96
97#endif // ANDROID_HARDWARE_TV_CEC_V1_0_HDMICEC_H