blob: 8af97060f149f047c8dabac2ce5ca8f7aecf30b6 [file] [log] [blame]
Venkatarama Avadhani90373fe2022-11-11 16:54:53 +05301/*
2 * Copyright (C) 2022 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
Venkatarama Avadhani601d2992022-12-12 22:29:30 +053017#include <aidl/android/hardware/tv/hdmi/earc/BnEArc.h>
18#include <aidl/android/hardware/tv/hdmi/earc/Result.h>
Venkatarama Avadhani90373fe2022-11-11 16:54:53 +053019#include <algorithm>
20#include <vector>
21
22using namespace std;
23
24namespace android {
25namespace hardware {
26namespace tv {
Venkatarama Avadhani601d2992022-12-12 22:29:30 +053027namespace hdmi {
Venkatarama Avadhani90373fe2022-11-11 16:54:53 +053028namespace earc {
29namespace implementation {
30
Venkatarama Avadhani601d2992022-12-12 22:29:30 +053031using ::aidl::android::hardware::tv::hdmi::earc::BnEArc;
32using ::aidl::android::hardware::tv::hdmi::earc::IEArc;
33using ::aidl::android::hardware::tv::hdmi::earc::IEArcCallback;
34using ::aidl::android::hardware::tv::hdmi::earc::IEArcStatus;
35using ::aidl::android::hardware::tv::hdmi::earc::Result;
Venkatarama Avadhani90373fe2022-11-11 16:54:53 +053036
37struct EArcMock : public BnEArc {
38 EArcMock();
39
40 ::ndk::ScopedAStatus setEArcEnabled(bool in_enabled) override;
41 ::ndk::ScopedAStatus isEArcEnabled(bool* _aidl_return) override;
42 ::ndk::ScopedAStatus setCallback(const std::shared_ptr<IEArcCallback>& in_callback) override;
43 ::ndk::ScopedAStatus getState(int32_t in_portId, IEArcStatus* _aidl_return) override;
44 ::ndk::ScopedAStatus getLastReportedAudioCapabilities(
45 int32_t in_portId, std::vector<uint8_t>* _aidl_return) override;
Sham Rathod8a68cbc2023-01-11 19:11:15 +053046 ::ndk::ScopedAStatus reportCapabilities(const std::vector<uint8_t>& capabilities,
Venkatarama Avadhani90373fe2022-11-11 16:54:53 +053047 int32_t portId);
48 ::ndk::ScopedAStatus changeState(const IEArcStatus status, int32_t portId);
49
50 private:
51 static void* __threadLoop(void* data);
52 void threadLoop();
53
54 private:
55 static void serviceDied(void* cookie);
56 std::shared_ptr<IEArcCallback> mCallback;
57
58 // Variables for the virtual EARC hal impl
59 std::vector<std::vector<uint8_t>> mCapabilities;
60 std::vector<IEArcStatus> mPortStatus;
61 bool mEArcEnabled = true;
62
63 // Port configuration
64 int mTotalPorts = 1;
65
66 // Testing variables
67 pthread_t mThreadId = 0;
68
69 ::ndk::ScopedAIBinder_DeathRecipient mDeathRecipient;
70};
71} // namespace implementation
72} // namespace earc
Venkatarama Avadhani601d2992022-12-12 22:29:30 +053073} // Namespace hdmi
Venkatarama Avadhani90373fe2022-11-11 16:54:53 +053074} // Namespace tv
75} // namespace hardware
76} // namespace android