1 /*
2  * Copyright (C) 2013-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 EMULATOR_CAMERA_HAL_HWL_HWL_UTILS_H_
18 #define EMULATOR_CAMERA_HAL_HWL_HWL_UTILS_H_
19 
20 #include "EmulatedSensor.h"
21 #include "hal_types.h"
22 #include "hwl_types.h"
23 #include "system/camera_metadata.h"
24 
25 #ifndef ARRAY_SIZE
26 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
27 #endif
28 
29 #ifndef RAT_TO_FLOAT
30 #define RAT_TO_FLOAT(a) (static_cast<float>(a.numerator) / a.denominator)
31 #endif
32 
33 namespace android {
34 
35 using google_camera_hal::CameraDeviceStatus;
36 using google_camera_hal::HalCameraMetadata;
37 using std::pair;
38 using std::unique_ptr;
39 using std::unordered_map;
40 
41 typedef unordered_map<uint32_t, pair<CameraDeviceStatus, unique_ptr<HalCameraMetadata>>>
42     PhysicalDeviceMap;
43 typedef std::unique_ptr<PhysicalDeviceMap> PhysicalDeviceMapPtr;
44 
45 // Metadata utility functions start
46 bool HasCapability(const HalCameraMetadata* metadata, uint8_t capability);
47 status_t GetSensorCharacteristics(const HalCameraMetadata* metadata,
48                                   SensorCharacteristics* sensor_chars /*out*/);
49 PhysicalDeviceMapPtr ClonePhysicalDeviceMap(const PhysicalDeviceMapPtr& src);
50 // Metadata utility functions end
51 
52 }  // namespace android
53 
54 #endif  // EMULATOR_CAMERA_HAL_HWL_HWL_UTILS_H_
55