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_GOOGLE_CAMERA_HAL_HAL_UTILS_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_HAL_UTILS_H_ 19 20 #include "hal_types.h" 21 #include "hwl_types.h" 22 #include "process_block.h" 23 #include "utils.h" 24 25 namespace android { 26 namespace google_camera_hal { 27 namespace hal_utils { 28 29 // Create a HWL pipeline request for a pipeline based on a capture request. 30 status_t CreateHwlPipelineRequest(HwlPipelineRequest* hwl_request, 31 uint32_t pipeline_id, 32 const CaptureRequest& request); 33 34 // Create a vector of sychrounous HWL pipeline requests for pipelines 35 // based on capture requests. 36 // pipeline_ids and requests must have the same size. 37 // One HWL request will be created for each pair of a pipeline ID and a request. 38 status_t CreateHwlPipelineRequests( 39 std::vector<HwlPipelineRequest>* hwl_requests, 40 const std::vector<uint32_t>& pipeline_ids, 41 const std::vector<ProcessBlockRequest>& requests); 42 43 // Convert a HWL result to a capture result. 44 std::unique_ptr<CaptureResult> ConvertToCaptureResult( 45 std::unique_ptr<HwlPipelineResult> hwl_result); 46 47 // Return if the request contains an output buffer. 48 bool ContainsOutputBuffer(const CaptureRequest& request, 49 const buffer_handle_t& buffer); 50 51 // Return if all output buffers in remaining_session_request are included in 52 // process_block_requests. 53 bool AreAllRemainingBuffersRequested( 54 const std::vector<ProcessBlockRequest>& process_block_requests, 55 const CaptureRequest& remaining_session_request); 56 57 // Return if this is an IR camera. 58 bool IsIrCamera(const HalCameraMetadata* characteristics); 59 60 // Return if this is an MONO camera. 61 bool IsMonoCamera(const HalCameraMetadata* characteristics); 62 63 // Return if this is a bayer camera. 64 bool IsBayerCamera(const HalCameraMetadata* characteristics); 65 66 // Return if this is a HDR+ request 67 bool IsRequestHdrplusCompatible(const CaptureRequest& request, 68 int32_t preview_stream_id); 69 70 // Return if HDR+ stream is supported 71 bool IsStreamHdrplusCompatible(const StreamConfiguration& stream_config, 72 const HalCameraMetadata* characteristics); 73 74 // Set ANDROID_CONTROL_ENABLE_ZSL metadata 75 status_t SetEnableZslMetadata(HalCameraMetadata* metadata, bool enable); 76 77 // Set hybrid AE vendor tag 78 status_t SetHybridAeMetadata(HalCameraMetadata* metadata, bool enable); 79 80 // Modify the request of realtime pipeline for HDR+ 81 status_t ModifyRealtimeRequestForHdrplus(HalCameraMetadata* metadata, 82 const bool hybrid_ae_enable = true); 83 84 // Get ANDROID_STATISTICS_FACE_DETECT_MODE 85 status_t GetFdMode(const CaptureRequest& request, uint8_t* face_detect_mode); 86 87 // Remove face detect information 88 status_t RemoveFdInfoFromResult(HalCameraMetadata* metadata); 89 90 // Force lens shading map mode on 91 status_t ForceLensShadingMapModeOn(HalCameraMetadata* metadata); 92 93 // Get lens shading map mode 94 status_t GetLensShadingMapMode(const CaptureRequest& request, 95 uint8_t* lens_shading_mode); 96 97 // Remove lens shading information 98 status_t RemoveLsInfoFromResult(HalCameraMetadata* metadata); 99 100 // Dump the information in the stream configuration 101 void DumpStreamConfiguration(const StreamConfiguration& stream_configuration, 102 std::string title); 103 104 // Dump the information in the HAL configured streams 105 void DumpHalConfiguredStreams( 106 const std::vector<HalStream>& hal_configured_streams, std::string title); 107 108 // Dump the information in a capture request 109 void DumpCaptureRequest(const CaptureRequest& request, std::string title); 110 111 // Dump the information in a capture result 112 void DumpCaptureResult(const ProcessBlockResult& result, std::string title); 113 114 // Dump the information in a capture result 115 void DumpCaptureResult(const CaptureResult& result, std::string title); 116 117 // Dump the information in a notification 118 void DumpNotify(const NotifyMessage& message, std::string title); 119 120 // Dump Stream 121 void DumpStream(const Stream& stream, std::string title); 122 123 // Dump HalStream 124 void DumpHalStream(const HalStream& hal_stream, std::string title); 125 126 // Dump the information in a buffer return 127 void DumpBufferReturn(const std::vector<StreamBuffer>& stream_buffers, 128 std::string title); 129 130 // Dump the information in a buffer request 131 void DumpBufferRequest(const std::vector<BufferRequest>& hal_buffer_requests, 132 const std::vector<BufferReturn>* hal_buffer_returns, 133 std::string title); 134 135 } // namespace hal_utils 136 } // namespace google_camera_hal 137 } // namespace android 138 139 #endif // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_HAL_UTILS_H_