• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef CPP_EVS_MANAGER_AIDL_UTILS_INCLUDE_UTILS_H
17 #define CPP_EVS_MANAGER_AIDL_UTILS_INCLUDE_UTILS_H
18 
19 #include <aidl/android/hardware/automotive/evs/BufferDesc.h>
20 #include <aidl/android/hardware/automotive/evs/CameraDesc.h>
21 #include <aidl/android/hardware/automotive/evs/CameraParam.h>
22 #include <aidl/android/hardware/automotive/evs/DisplayDesc.h>
23 #include <aidl/android/hardware/automotive/evs/DisplayState.h>
24 #include <aidl/android/hardware/automotive/evs/EvsEventDesc.h>
25 #include <aidl/android/hardware/automotive/evs/EvsEventType.h>
26 #include <aidl/android/hardware/automotive/evs/EvsResult.h>
27 #include <aidl/android/hardware/automotive/evs/Rotation.h>
28 #include <aidl/android/hardware/automotive/evs/Stream.h>
29 #include <aidl/android/hardware/automotive/evs/StreamType.h>
30 #include <aidl/android/hardware/common/NativeHandle.h>
31 #include <android-base/macros.h>
32 #include <android/hardware/automotive/evs/1.1/types.h>
33 #include <android/hardware/camera/device/3.2/ICameraDevice.h>
34 
35 namespace aidl::android::automotive::evs::implementation {
36 
37 namespace aidlevs = ::aidl::android::hardware::automotive::evs;
38 namespace aidlgfx = ::aidl::android::hardware::graphics;
39 namespace hidlevs = ::android::hardware::automotive::evs;
40 namespace hidlgfx = ::android::hardware::graphics;
41 
42 class Utils final {
43 public:
44     static aidlevs::DisplayState makeFromHidl(hidlevs::V1_0::DisplayState hidlState);
45 
46     static hidlevs::V1_0::DisplayState makeToHidl(aidlevs::DisplayState aidlState);
47 
48     static aidlgfx::common::HardwareBuffer makeHwBufferFromHidlBuffer(
49             const hidlevs::V1_0::BufferDesc& hidlBuffer, bool doDup);
50 
51     static aidlgfx::common::HardwareBuffer makeHwBufferFromHidlBuffer(
52             const hidlevs::V1_1::BufferDesc& hidlBuffer, bool doDup);
53 
54     static aidlevs::BufferDesc makeFromHidl(const hidlevs::V1_0::BufferDesc& hidlBuffer,
55                                             bool doDup = true);
56 
57     static aidlevs::BufferDesc makeFromHidl(const hidlevs::V1_1::BufferDesc& hidlBuffer,
58                                             bool doDup = true);
59 
60     static hidlevs::V1_0::BufferDesc makeToHidlV1_0(const aidlevs::BufferDesc& hidlBuffer,
61                                                     bool doDup = true);
62 
63     static hidlevs::V1_1::BufferDesc makeToHidlV1_1(const aidlevs::BufferDesc& hidlBuffer,
64                                                     bool doDup = true);
65 
66     static aidlgfx::common::HardwareBufferDescription makeFromHidl(
67             const hidlgfx::common::V1_2::HardwareBuffer& hidlBuffer);
68 
69     static aidlevs::EvsResult makeFromHidl(hidlevs::V1_0::EvsResult result);
70 
71     static hidlevs::V1_0::EvsResult makeToHidl(aidlevs::EvsResult result);
72 
73     static ::ndk::ScopedAStatus buildScopedAStatusFromEvsResult(aidlevs::EvsResult result);
74 
75     static ::ndk::ScopedAStatus buildScopedAStatusFromEvsResult(
76             ::android::hardware::Return<aidlevs::EvsResult>& result);
77 
78     static ::ndk::ScopedAStatus buildScopedAStatusFromEvsResult(hidlevs::V1_0::EvsResult result);
79 
80     static ::ndk::ScopedAStatus buildScopedAStatusFromEvsResult(
81             ::android::hardware::Return<hidlevs::V1_0::EvsResult>& result);
82 
83     static aidlevs::CameraDesc makeFromHidl(const hidlevs::V1_0::CameraDesc& desc);
84 
85     static aidlevs::CameraDesc makeFromHidl(const hidlevs::V1_1::CameraDesc& desc);
86 
87     static hidlevs::V1_0::CameraDesc makeToHidlV1_0(const aidlevs::CameraDesc& desc);
88 
89     static hidlevs::V1_1::CameraDesc makeToHidlV1_1(const aidlevs::CameraDesc& desc);
90 
91     static hidlevs::V1_1::CameraParam makeToHidl(aidlevs::CameraParam id);
92 
93     static aidlevs::CameraParam makeFromHidl(hidlevs::V1_1::CameraParam id);
94 
95     static aidlevs::DisplayDesc makeFromHidl(const hidlevs::V1_0::DisplayDesc& desc);
96 
97     static hidlevs::V1_1::EvsEventType makeToHidl(const aidlevs::EvsEventType& type);
98 
99     static aidlevs::EvsEventType makeFromHidl(const hidlevs::V1_1::EvsEventType& type);
100 
101     static bool makeToHidl(const aidlevs::EvsEventDesc& in, hidlevs::V1_1::EvsEventDesc* out);
102 
103     static aidlevs::EvsEventDesc makeFromHidl(const hidlevs::V1_1::EvsEventDesc& desc);
104 
105     static hidlgfx::common::V1_2::HardwareBuffer makeToHidl(
106             const aidlgfx::common::HardwareBuffer& aidlDesc, bool doDup = true);
107 
108     static hidlgfx::common::V1_2::HardwareBufferDescription makeToHidl(
109             const aidlgfx::common::HardwareBufferDescription& aidlDesc);
110 
111     static aidlevs::Stream makeFromHidl(
112             const ::android::hardware::camera::device::V3_2::Stream& hidlConfig);
113 
114     static aidlevs::StreamType makeFromHidl(
115             ::android::hardware::camera::device::V3_2::StreamType hidlType);
116 
117     static aidlevs::Rotation makeFromHidl(
118             ::android::hardware::camera::device::V3_2::StreamRotation hidlRotation);
119 
120     static ::android::hardware::camera::device::V3_2::Stream makeToHidl(
121             const aidlevs::Stream& aidlConfig);
122 
123     static ::android::hardware::camera::device::V3_2::StreamType makeToHidl(
124             aidlevs::StreamType aidlType);
125 
126     static ::android::hardware::camera::device::V3_2::StreamRotation makeToHidl(
127             aidlevs::Rotation aidlRotation);
128 
129     static bool validateNativeHandle(const ::aidl::android::hardware::common::NativeHandle& handle);
130 
131     static ::aidl::android::hardware::common::NativeHandle dupNativeHandle(
132             const ::aidl::android::hardware::common::NativeHandle& handle, bool doDup);
133 
134     static aidlgfx::common::HardwareBuffer dupHardwareBuffer(
135             const aidlgfx::common::HardwareBuffer& buffer, bool doDup);
136 
137     static aidlevs::BufferDesc dupBufferDesc(const aidlevs::BufferDesc& src, bool doDup);
138 
139     static std::string toString(const aidlevs::EvsEventType& type);
140 
141     static std::string_view toString(aidlevs::EvsResult result);
142 
143     DISALLOW_IMPLICIT_CONSTRUCTORS(Utils);
144 };
145 
146 }  // namespace aidl::android::automotive::evs::implementation
147 
148 #endif  // CPP_EVS_MANAGER_AIDL_UTILS_INCLUDE_UTILS_H
149