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   // Dump the camera device states in fd, using dprintf() or write().
62   virtual status_t DumpState(int fd) = 0;
63 
64   // Create a camera device session for this device. This method will not be
65   // called before previous session has been destroyed.
66   // Created CameraDeviceSession remain valid even after this CameraDevice
67   // instance is destroyed.
68   // camera_allocator_hwl will be used by the HWL session when create HW
69   // pipeline, it should be valid during the lifetime of the HWL session.
70   virtual status_t CreateCameraDeviceSessionHwl(
71       CameraBufferAllocatorHwl* camera_allocator_hwl,
72       std::unique_ptr<CameraDeviceSessionHwl>* session) = 0;
73 
74   // Query whether a particular logical and physical streams combination are
75   // supported. stream_config contains the stream configurations.
76   virtual bool IsStreamCombinationSupported(
77       const StreamConfiguration& stream_config) = 0;
78 
79   // Get customized profiler
GetProfiler(uint32_t,int)80   virtual std::unique_ptr<google::camera_common::Profiler> GetProfiler(
81       uint32_t /* camera_id */, int /* option */) {
82     return nullptr;
83   }
84 };
85 
86 }  // namespace google_camera_hal
87 }  // namespace android
88 
89 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_CAMERA_DEVICE_HWL_H_