• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "physical_camera_info_hwl.h"
27 #include "profiler.h"
28 
29 namespace android {
30 namespace google_camera_hal {
31 
32 // Camera device HWL, which is associated with a certain camera ID. The camera
33 // device can be a logical camera that contains multiple physical camera, or
34 // a single physical camera. It provides methods to query static information
35 // about the associated camera devices. It does not hold any states of the
36 // camera device.
37 class CameraDeviceHwl : public PhysicalCameraInfoHwl {
38  public:
39   virtual ~CameraDeviceHwl() = default;
40 
41   // Get the camera ID of this camera device HWL.
42   virtual uint32_t GetCameraId() const = 0;
43 
44   // Get the resource cost of this camera device HWL.
45   virtual status_t GetResourceCost(CameraResourceCost* cost) const = 0;
46 
47   // Get the characteristics of this camera device HWL.
48   // characteristics will be filled by CameraDeviceHwl.
49   virtual status_t GetCameraCharacteristics(
50       std::unique_ptr<HalCameraMetadata>* characteristics) const = 0;
51 
52   // For certain feature combinations, some keys in camera characteristics
53   // have more limited support range compared with that returned by
54   // GetCameraCharacterics. This function will return the limited values of the
55   // keys listed in CameraCharacteristics#getAvailableSessionCharacteristicsKeys
56   // for the input StreamConfiguration.
57   //
58   // stream_config includes the requested streams and session settings for
59   // which we are going to fetch the characteristics.
60   //
61   // session_characteristic will be filled with the session characteristics keys
62   // with their limited ranges.
63   virtual status_t GetSessionCharacteristics(
64       const StreamConfiguration& session_config,
65       std::unique_ptr<HalCameraMetadata>& characteristics) const = 0;
66 
67   // Get the characteristics of the physical camera of this camera device.
68   // characteristics will be filled by CameraDeviceHwl.
69   virtual status_t GetPhysicalCameraCharacteristics(
70       uint32_t physical_camera_id,
71       std::unique_ptr<HalCameraMetadata>* characteristics) const = 0;
72 
73   // Set the torch mode of the camera device. The torch mode status remains
74   // unchanged after this CameraDevice instance is destroyed.
75   virtual status_t SetTorchMode(TorchMode mode) = 0;
76 
77   // Change the torch strength level of this camera device. If the torch is OFF
78   // and torchStrength > 0, then the torch will turn ON.
TurnOnTorchWithStrengthLevel(int32_t)79   virtual status_t TurnOnTorchWithStrengthLevel(int32_t /*torch_strength*/) {
80     return UNKNOWN_TRANSACTION;
81   }
82 
83   // Get the torch strength level of this camera device HWL.
GetTorchStrengthLevel(int32_t &)84   virtual status_t GetTorchStrengthLevel(int32_t& /*torch_strength*/) const {
85     return UNKNOWN_TRANSACTION;
86   }
87 
88   // Construct default request settings
89   virtual status_t ConstructDefaultRequestSettings(
90       RequestTemplate type,
91       std::unique_ptr<HalCameraMetadata>* request_settings) = 0;
92 
93   // Dump the camera device states in fd, using dprintf() or write().
94   virtual status_t DumpState(int fd) = 0;
95 
96   // Create a camera device session for this device. This method will not be
97   // called before previous session has been destroyed.
98   // Created CameraDeviceSession remain valid even after this CameraDevice
99   // instance is destroyed.
100   // camera_allocator_hwl will be used by the HWL session when create HW
101   // pipeline, it should be valid during the lifetime of the HWL session.
102   virtual status_t CreateCameraDeviceSessionHwl(
103       CameraBufferAllocatorHwl* camera_allocator_hwl,
104       std::unique_ptr<CameraDeviceSessionHwl>* session) = 0;
105 
106   // Query whether a particular streams configuration is supported.
107   // stream_config: It contains the stream info and session settings.
108   // check_settings: When check_settings is true, this function will check if
109   // the input session settings in stream_config is supported. The keys camera
110   // hwl has to scan for reporting support status is defined in framework by
111   // CameraCharacteristics#INFO_SESSION_CONFIGURATION_QUERY_VERSION.
112   virtual bool IsStreamCombinationSupported(
113       const StreamConfiguration& stream_config,
114       const bool check_settings) const = 0;
115 
116   // Get customized profiler
GetProfiler(uint32_t,int)117   virtual std::unique_ptr<google::camera_common::Profiler> GetProfiler(
118       uint32_t /* camera_id */, int /* option */) {
119     return nullptr;
120   }
121 };
122 
123 }  // namespace google_camera_hal
124 }  // namespace android
125 
126 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_CAMERA_DEVICE_HWL_H_
127