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 HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_CAMERA_DEVICE_HWL_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_CAMERA_DEVICE_HWL_H_ 19 20 #include <utils/Errors.h> 21 22 #include "camera_buffer_allocator_hwl.h" 23 #include "camera_device_session_hwl.h" 24 #include "hal_camera_metadata.h" 25 #include "hal_types.h" 26 #include "profiler.h" 27 28 namespace android { 29 namespace google_camera_hal { 30 31 // Camera device HWL, which is associated with a certain camera ID. The camera 32 // device can be a logical camera that contains multiple physical camera, or 33 // a single physical camera. It provides methods to query static information 34 // about the associated camera devices. It does not hold any states of the 35 // camera device. 36 class CameraDeviceHwl { 37 public: 38 virtual ~CameraDeviceHwl() = default; 39 40 // Get the camera ID of this camera device HWL. 41 virtual uint32_t GetCameraId() const = 0; 42 43 // Get the resource cost of this camera device HWL. 44 virtual status_t GetResourceCost(CameraResourceCost* cost) const = 0; 45 46 // Get the characteristics of this camera device HWL. 47 // characteristics will be filled by CameraDeviceHwl. 48 virtual status_t GetCameraCharacteristics( 49 std::unique_ptr<HalCameraMetadata>* characteristics) const = 0; 50 51 // Get the characteristics of the physical camera of this camera device. 52 // characteristics will be filled by CameraDeviceHwl. 53 virtual status_t GetPhysicalCameraCharacteristics( 54 uint32_t physical_camera_id, 55 std::unique_ptr<HalCameraMetadata>* characteristics) const = 0; 56 57 // Set the torch mode of the camera device. The torch mode status remains 58 // unchanged after this CameraDevice instance is destroyed. 59 virtual status_t SetTorchMode(TorchMode mode) = 0; 60 61 // Change the torch strength level of this camera device. If the torch is OFF 62 // and torchStrength > 0, then the torch will turn ON. TurnOnTorchWithStrengthLevel(int32_t)63 virtual status_t TurnOnTorchWithStrengthLevel(int32_t /*torch_strength*/) { 64 return UNKNOWN_TRANSACTION; 65 } 66 67 // Get the torch strength level of this camera device HWL. GetTorchStrengthLevel(int32_t &)68 virtual status_t GetTorchStrengthLevel(int32_t& /*torch_strength*/) const { 69 return UNKNOWN_TRANSACTION; 70 } 71 72 // Dump the camera device states in fd, using dprintf() or write(). 73 virtual status_t DumpState(int fd) = 0; 74 75 // Create a camera device session for this device. This method will not be 76 // called before previous session has been destroyed. 77 // Created CameraDeviceSession remain valid even after this CameraDevice 78 // instance is destroyed. 79 // camera_allocator_hwl will be used by the HWL session when create HW 80 // pipeline, it should be valid during the lifetime of the HWL session. 81 virtual status_t CreateCameraDeviceSessionHwl( 82 CameraBufferAllocatorHwl* camera_allocator_hwl, 83 std::unique_ptr<CameraDeviceSessionHwl>* session) = 0; 84 85 // Query whether a particular logical and physical streams combination are 86 // supported. stream_config contains the stream configurations. 87 virtual bool IsStreamCombinationSupported( 88 const StreamConfiguration& stream_config) = 0; 89 90 // Get customized profiler GetProfiler(uint32_t,int)91 virtual std::unique_ptr<google::camera_common::Profiler> GetProfiler( 92 uint32_t /* camera_id */, int /* option */) { 93 return nullptr; 94 } 95 }; 96 97 } // namespace google_camera_hal 98 } // namespace android 99 100 #endif // HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_CAMERA_DEVICE_HWL_H_