• 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_HWL_TYPES_H_
18 #define HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_HWL_TYPES_H_
19 
20 #include "hal_types.h"
21 
22 namespace android {
23 namespace google_camera_hal {
24 
25 // Enumerates pipeline roles that are used to communicate with HWL.
26 enum class HwlOfflinePipelineRole {
27   kOfflineInvalidRole = 0,
28   kOfflineSmoothTransitionRole,
29   kOfflineHdrplusRole,
30 };
31 
32 // Define a HWL pipeline request.
33 struct HwlPipelineRequest {
34   // ID of the pipeline that this request should be submitted to.
35   uint32_t pipeline_id = 0;
36 
37   std::unique_ptr<HalCameraMetadata> settings;
38 
39   // If empty, the output buffers are captured from the camera sensors. If
40   // not empty, the output buffers are captured from the input buffers.
41   std::vector<StreamBuffer> input_buffers;
42 
43   // The metadata of the input_buffers. This is used for multi-frame merging
44   // like HDR+.
45   std::vector<std::unique_ptr<HalCameraMetadata>> input_buffer_metadata;
46 
47   std::vector<StreamBuffer> output_buffers;
48 
49   // Maps from physical camera ID to physical camera settings.
50   std::unordered_map<uint32_t, std::unique_ptr<HalCameraMetadata>>
51       physical_camera_settings;
52 
53   int32_t input_width;
54   int32_t input_height;
55 };
56 
57 // Define a HWL pipeline result.
58 struct HwlPipelineResult {
59   // camera_id, pipeline_id, frame_number should match those in the original
60   // request.
61   uint32_t camera_id = 0;
62   uint32_t pipeline_id = 0;
63   uint32_t frame_number = 0;
64 
65   // result_metadata, input_buffers, and output_buffers can be returned
66   // separately.
67   std::unique_ptr<HalCameraMetadata> result_metadata;
68   std::vector<StreamBuffer> input_buffers;
69   std::vector<StreamBuffer> output_buffers;
70 
71   // Maps from physical camera ID to physical camera results.
72   // Only to be used for logical cameras that receive requests
73   // with output buffers belonging to streams tied to physical devices.
74   std::unordered_map<uint32_t, std::unique_ptr<HalCameraMetadata>>
75       physical_camera_results;
76 
77   uint32_t partial_result = 0;
78 };
79 
80 // Callback to invoke to send a result from HWL.
81 using HwlProcessPipelineResultFunc =
82     std::function<void(std::unique_ptr<HwlPipelineResult> /*result*/)>;
83 
84 // Callback to invoke to notify a message from HWL.
85 using NotifyHwlPipelineMessageFunc = std::function<void(
86     uint32_t /*pipeline_id*/, const NotifyMessage& /*message*/)>;
87 
88 // Defines callbacks to notify from a HWL pipeline.
89 struct HwlPipelineCallback {
90   // Callback to notify when a HWL pipeline produces a capture result.
91   HwlProcessPipelineResultFunc process_pipeline_result;
92 
93   // Callback to notify shutters or errors.
94   NotifyHwlPipelineMessageFunc notify;
95 };
96 
97 // Callback to invoke to request buffers from HAL. Only in case of HFR, there
98 // is a chance for the client to ask for more than one buffer each time
99 // (in batch).
100 // TODO(b/134959043): a more decoupled implementation of HAL Buffer Management
101 //                    allowos us to remove the frame_number from the arg list.
102 using HwlRequestBuffersFunc = std::function<status_t(
103     uint32_t /*stream_id*/, uint32_t /*num_buffers*/,
104     std::vector<StreamBuffer>* /*buffers*/, uint32_t /*frame_number*/)>;
105 
106 // Callback to invoke to return buffers, acquired by HwlRequestBuffersFunc,
107 // to HAL.
108 using HwlReturnBuffersFunc =
109     std::function<void(const std::vector<StreamBuffer>& /*buffers*/)>;
110 
111 // Defines callbacks to invoke from a HWL session.
112 struct HwlSessionCallback {
113   // Callback to request stream buffers.
114   HwlRequestBuffersFunc request_stream_buffers;
115 
116   // Callback to return stream buffers.
117   HwlReturnBuffersFunc return_stream_buffers;
118 };
119 
120 // Callback defined from framework to indicate the state of camera device
121 // has changed.
122 using HwlCameraDeviceStatusChangeFunc =
123     std::function<void(uint32_t /*camera_id*/, CameraDeviceStatus /*new_status*/)>;
124 
125 // Callback defined from framework to indicate the state of physical camera
126 // device has changed.
127 using HwlPhysicalCameraDeviceStatusChangeFunc =
128     std::function<void(uint32_t /*camera_id*/, uint32_t /*physical_camera_id*/,
129                        CameraDeviceStatus /*new_status*/)>;
130 
131 // Callback defined from framework to indicate the state of the torch mode
132 // has changed.
133 using HwlTorchModeStatusChangeFunc =
134     std::function<void(uint32_t /*camera_id*/, TorchModeStatus /*new_status*/)>;
135 
136 // Defines callbacks to notify when a status changed.
137 struct HwlCameraProviderCallback {
138   // Callback to notify when a camera device's status changed.
139   HwlCameraDeviceStatusChangeFunc camera_device_status_change;
140 
141   // Callback to notify when a physical camera device's status changed.
142   HwlPhysicalCameraDeviceStatusChangeFunc physical_camera_device_status_change;
143 
144   // Callback to notify when a torch mode status changed.
145   HwlTorchModeStatusChangeFunc torch_mode_status_change;
146 };
147 
148 }  // namespace google_camera_hal
149 }  // namespace android
150 
151 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_HWL_TYPES_H_
152