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 50 // Define a HWL pipeline result. 51 struct HwlPipelineResult { 52 // camera_id, pipeline_id, frame_number should match those in the original 53 // request. 54 uint32_t camera_id = 0; 55 uint32_t pipeline_id = 0; 56 uint32_t frame_number = 0; 57 58 // result_metadata, input_buffers, and output_buffers can be returned 59 // separately. 60 std::unique_ptr<HalCameraMetadata> result_metadata; 61 std::vector<StreamBuffer> input_buffers; 62 std::vector<StreamBuffer> output_buffers; 63 64 // Maps from physical camera ID to physical camera results. 65 // Only to be used for logical cameras that receive requests 66 // with output buffers belonging to streams tied to physical devices. 67 std::unordered_map<uint32_t, std::unique_ptr<HalCameraMetadata>> 68 physical_camera_results; 69 70 uint32_t partial_result = 0; 71 }; 72 73 // Callback to invoke to send a result from HWL. 74 using HwlProcessPipelineResultFunc = 75 std::function<void(std::unique_ptr<HwlPipelineResult> /*result*/)>; 76 77 // Callback to invoke to notify a message from HWL. 78 using NotifyHwlPipelineMessageFunc = std::function<void( 79 uint32_t /*pipeline_id*/, const NotifyMessage& /*message*/)>; 80 81 // Defines callbacks to notify from a HWL pipeline. 82 struct HwlPipelineCallback { 83 // Callback to notify when a HWL pipeline produces a capture result. 84 HwlProcessPipelineResultFunc process_pipeline_result; 85 86 // Callback to notify shutters or errors. 87 NotifyHwlPipelineMessageFunc notify; 88 }; 89 90 // Callback to invoke to request buffers from HAL. Only in case of HFR, there 91 // is a chance for the client to ask for more than one buffer each time 92 // (in batch). 93 // TODO(b/134959043): a more decoupled implementation of HAL Buffer Management 94 // allowos us to remove the frame_number from the arg list. 95 using HwlRequestBuffersFunc = std::function<status_t( 96 uint32_t /*stream_id*/, uint32_t /*num_buffers*/, 97 std::vector<StreamBuffer>* /*buffers*/, uint32_t /*frame_number*/)>; 98 99 // Callback to invoke to return buffers, acquired by HwlRequestBuffersFunc, 100 // to HAL. 101 using HwlReturnBuffersFunc = 102 std::function<void(const std::vector<StreamBuffer>& /*buffers*/)>; 103 104 // Defines callbacks to invoke from a HWL session. 105 struct HwlSessionCallback { 106 // Callback to request stream buffers. 107 HwlRequestBuffersFunc request_stream_buffers; 108 109 // Callback to return stream buffers. 110 HwlReturnBuffersFunc return_stream_buffers; 111 }; 112 113 // Callback defined from framework to indicate the state of camera device 114 // has changed. 115 using HwlCameraDeviceStatusChangeFunc = 116 std::function<void(uint32_t /*camera_id*/, CameraDeviceStatus /*new_status*/)>; 117 118 // Callback defined from framework to indicate the state of physical camera 119 // device has changed. 120 using HwlPhysicalCameraDeviceStatusChangeFunc = 121 std::function<void(uint32_t /*camera_id*/, uint32_t /*physical_camera_id*/, 122 CameraDeviceStatus /*new_status*/)>; 123 124 // Callback defined from framework to indicate the state of the torch mode 125 // has changed. 126 using HwlTorchModeStatusChangeFunc = 127 std::function<void(uint32_t /*camera_id*/, TorchModeStatus /*new_status*/)>; 128 129 // Defines callbacks to notify when a status changed. 130 struct HwlCameraProviderCallback { 131 // Callback to notify when a camera device's status changed. 132 HwlCameraDeviceStatusChangeFunc camera_device_status_change; 133 134 // Callback to notify when a physical camera device's status changed. 135 HwlPhysicalCameraDeviceStatusChangeFunc physical_camera_device_status_change; 136 137 // Callback to notify when a torch mode status changed. 138 HwlTorchModeStatusChangeFunc torch_mode_status_change; 139 }; 140 141 } // namespace google_camera_hal 142 } // namespace android 143 144 #endif // HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_HWL_TYPES_H_ 145