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_SESSION_HWL_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_CAMERA_DEVICE_SESSION_HWL_H_ 19 20 #include <utils/Errors.h> 21 22 #include "hal_camera_metadata.h" 23 #include "hwl_types.h" 24 #include "multicam_coordinator_hwl.h" 25 #include "session_data_defs.h" 26 #include "zoom_ratio_mapper_hwl.h" 27 28 namespace android { 29 namespace google_camera_hal { 30 31 // CameraDeviceSessionHwl provides methods to return default settings, 32 // create pipelines, submit capture requests, and flush the session. 33 class CameraDeviceSessionHwl { 34 public: 35 virtual ~CameraDeviceSessionHwl() = default; 36 37 // Construct the default request settings for a request template type. 38 virtual status_t ConstructDefaultRequestSettings( 39 RequestTemplate type, 40 std::unique_ptr<HalCameraMetadata>* default_settings) = 0; 41 42 virtual status_t PrepareConfigureStreams( 43 const StreamConfiguration& request_config) = 0; 44 45 // To create pipelines for a capture session, the client will call 46 // ConfigurePipeline() to configure each pipeline, and call BuildPipelines() 47 // to build all successfully configured pipelines. If a ConfigurePipeline() 48 // returns an error, BuildPipelines() will not build that failed pipeline 49 // configuration. If ConfigurePipeline() is called when previously built 50 // pipelines have not been destroyed, it will return ALREADY_EXISTS. If 51 // DestroyPipelines() is call after ConfigurePipeline(), it will reset 52 // and discard the configured pipelines. 53 // 54 // camera ID specifies which camera this pipeline captures requests from. It 55 // will be one of the camera IDs returned from GetCameraId() and 56 // GetPhysicalCameraIds(). 57 // hwl_pipeline_callback contains callback functions to notify results and 58 // messages. 59 // request_config is the requested stream configuration for one pipeline. 60 // overall_config is the complete requested stream configuration from 61 // frameworks. 62 // pipeline_id is an unique pipeline ID filled by this method. It can be used 63 // to submit requests to a specific pipeline in SubmitRequests(). 64 virtual status_t ConfigurePipeline(uint32_t camera_id, 65 HwlPipelineCallback hwl_pipeline_callback, 66 const StreamConfiguration& request_config, 67 const StreamConfiguration& overall_config, 68 uint32_t* pipeline_id) = 0; 69 70 // Build the successfully configured pipelines from ConfigurePipeline(). If 71 // there is no successfully configured pipeline, this method will return 72 // NO_INIT. 73 virtual status_t BuildPipelines() = 0; 74 75 // Warm up pipeline to ready for taking request, this can be a NoOp for 76 // implementation which doesn't support to put pipeline in standby mode 77 // This call is optional for capture session before sending request. only 78 // needed when capture session want to confirm if the pipeline is ready before 79 // sending request, otherwise HWL session should implicitly get back to ready 80 // state after receiving a request.Multiple pipelines in the same session can 81 // be prepared in parallel by calling this function. 82 // pipeline_id is the id returned from ConfigurePipeline 83 // frame_number is the request frame number when call this interface 84 virtual status_t PreparePipeline(uint32_t pipeline_id, 85 uint32_t frame_number) = 0; 86 87 // Fills required input streams for a certain offline pipeline. Returns an 88 // error if the pipeline being queried is not an offline pipeline. 89 // overall_config is the requested configuration from framework. 90 // pipeline_role is the role of the offline pipeline to query for. 91 // streams is a vector of required input streams to return. 92 virtual status_t GetRequiredIntputStreams( 93 const StreamConfiguration& overall_config, 94 HwlOfflinePipelineRole pipeline_role, std::vector<Stream>* streams) = 0; 95 96 // Get the configured HAL streams for a pipeline. If no pipeline was built, 97 // this method will return NO_INIT. If pipeline_id was not built, this method 98 // will return NAME_NOT_FOUND. 99 virtual status_t GetConfiguredHalStream( 100 uint32_t pipeline_id, std::vector<HalStream>* hal_streams) const = 0; 101 102 // Destroy built pipelines or discard configured pipelines. 103 virtual void DestroyPipelines() = 0; 104 105 // frame_number is the frame number of the requests. 106 // requests contain requests from all different pipelines. If requests contain 107 // more than one request from a certain pipeline, this method will return an 108 // error. All requests captured from camera sensors must be captured 109 // synchronously. 110 virtual status_t SubmitRequests( 111 uint32_t frame_number, 112 const std::vector<HwlPipelineRequest>& requests) = 0; 113 114 // Flush all pending requests. 115 virtual status_t Flush() = 0; 116 117 // Return the camera ID that this camera device session is associated with. 118 virtual uint32_t GetCameraId() const = 0; 119 120 // Return the physical camera ID that this camera device session is associated 121 // with. If the camera device does not have multiple physical camera devices, 122 // this method should return an empty std::vector. 123 virtual std::vector<uint32_t> GetPhysicalCameraIds() const = 0; 124 125 // Return the characteristics that this camera device session is associated with. 126 virtual status_t GetCameraCharacteristics( 127 std::unique_ptr<HalCameraMetadata>* characteristics) const = 0; 128 129 // Return the characteristics of a physical camera belonging to this device session. 130 virtual status_t GetPhysicalCameraCharacteristics( 131 uint32_t physical_camera_id, 132 std::unique_ptr<HalCameraMetadata>* characteristics) const = 0; 133 134 // See common/session_data_def.h for more info on Session Data API 135 // Set a key/value pair for this session 136 virtual status_t SetSessionData(SessionDataKey key, void* value) = 0; 137 138 // Get the value corresponding to the give key in the session 139 virtual status_t GetSessionData(SessionDataKey key, void** value) const = 0; 140 141 // Set the session callback. 142 virtual void SetSessionCallback( 143 const HwlSessionCallback& hwl_session_callback) = 0; 144 145 // Filter out the result metadata to remove any private metadata that is meant 146 // to be internal to the HWL and should not be delivered to the upper layer. 147 // Unless the request specified intermediate processing via 148 // VendorTagIds::kProcessingMode, the HWL impelmentation should by default 149 // remove any private data from the result metadata. 150 virtual status_t FilterResultMetadata(HalCameraMetadata* metadata) const = 0; 151 152 // Return the corresponding HWL coordinator utility interface 153 virtual std::unique_ptr<IMulticamCoordinatorHwl> 154 CreateMulticamCoordinatorHwl() = 0; 155 156 // Check reconfiguration is required or not 157 // old_session is old session parameter 158 // new_session is new session parameter 159 // If reconfiguration is required, set reconfiguration_required to true 160 // If reconfiguration is not required, set reconfiguration_required to false 161 virtual status_t IsReconfigurationRequired( 162 const HalCameraMetadata* old_session, const HalCameraMetadata* new_session, 163 bool* reconfiguration_required) const = 0; 164 165 // Get zoom ratio mapper from HWL. 166 virtual std::unique_ptr<ZoomRatioMapperHwl> GetZoomRatioMapperHwl() = 0; 167 }; 168 169 } // namespace google_camera_hal 170 } // namespace android 171 172 #endif // HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_CAMERA_DEVICE_SESSION_HWL_H_ 173