1 /* 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 EMULATOR_CAMERA_HAL_HWL_CAMERA_DEVICE_HWL_H 18 #define EMULATOR_CAMERA_HAL_HWL_CAMERA_DEVICE_HWL_H 19 20 #include <camera_device_hwl.h> 21 #include <hal_types.h> 22 23 #include "EmulatedSensor.h" 24 #include "EmulatedTorchState.h" 25 #include "utils/HWLUtils.h" 26 #include "utils/StreamConfigurationMap.h" 27 28 namespace android { 29 30 using google_camera_hal::CameraBufferAllocatorHwl; 31 using google_camera_hal::CameraDeviceHwl; 32 using google_camera_hal::CameraDeviceSessionHwl; 33 using google_camera_hal::CameraResourceCost; 34 using google_camera_hal::HalCameraMetadata; 35 using google_camera_hal::StreamConfiguration; 36 using google_camera_hal::TorchMode; 37 38 class EmulatedCameraDeviceHwlImpl : public CameraDeviceHwl { 39 public: 40 static std::unique_ptr<CameraDeviceHwl> Create( 41 uint32_t camera_id, std::unique_ptr<HalCameraMetadata> static_meta, 42 PhysicalDeviceMapPtr physical_devices, 43 std::shared_ptr<EmulatedTorchState> torch_state); 44 45 virtual ~EmulatedCameraDeviceHwlImpl() = default; 46 47 // Override functions in CameraDeviceHwl. 48 uint32_t GetCameraId() const override; 49 50 status_t GetResourceCost(CameraResourceCost* cost) const override; 51 52 status_t GetCameraCharacteristics( 53 std::unique_ptr<HalCameraMetadata>* characteristics) const override; 54 55 status_t GetPhysicalCameraCharacteristics( 56 uint32_t physical_camera_id, 57 std::unique_ptr<HalCameraMetadata>* characteristics) const override; 58 59 status_t SetTorchMode(TorchMode mode) override; 60 61 status_t TurnOnTorchWithStrengthLevel(int32_t torch_strength) override; 62 63 status_t GetTorchStrengthLevel(int32_t& torch_strength) const override; 64 65 status_t DumpState(int fd) override; 66 67 status_t CreateCameraDeviceSessionHwl( 68 CameraBufferAllocatorHwl* camera_allocator_hwl, 69 std::unique_ptr<CameraDeviceSessionHwl>* session) override; 70 71 bool IsStreamCombinationSupported( 72 const StreamConfiguration& stream_config) override; 73 74 // End of override functions in CameraDeviceHwl. 75 76 private: 77 EmulatedCameraDeviceHwlImpl(uint32_t camera_id, 78 std::unique_ptr<HalCameraMetadata> static_meta, 79 PhysicalDeviceMapPtr physical_devices, 80 std::shared_ptr<EmulatedTorchState> torch_state); 81 82 status_t Initialize(); 83 84 int32_t GetDefaultTorchStrengthLevel() const; 85 int32_t GetMaximumTorchStrengthLevel() const; 86 87 const uint32_t camera_id_ = 0; 88 89 std::unique_ptr<HalCameraMetadata> static_metadata_; 90 std::unique_ptr<StreamConfigurationMap> stream_configuration_map_; 91 std::unique_ptr<StreamConfigurationMap> stream_configuration_map_max_resolution_; 92 PhysicalStreamConfigurationMap physical_stream_configuration_map_; 93 PhysicalStreamConfigurationMap physical_stream_configuration_map_max_resolution_; 94 PhysicalDeviceMapPtr physical_device_map_; 95 std::shared_ptr<EmulatedTorchState> torch_state_; 96 LogicalCharacteristics sensor_chars_; 97 int32_t default_torch_strength_level_ = 0; 98 int32_t maximum_torch_strength_level_ = 0; 99 100 }; 101 102 } // namespace android 103 104 #endif // EMULATOR_CAMERA_HAL_HWL_CAMERA_DEVICE_HWL_H 105