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_REALTIME_ZSL_REQUEST_PROCESSOR_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_REQUEST_PROCESSOR_H_ 19 20 #include <shared_mutex> 21 #include "process_block.h" 22 #include "request_processor.h" 23 #include "vendor_tag_types.h" 24 25 namespace android { 26 namespace google_camera_hal { 27 28 // RealtimeZslRequestProcessor implements a RequestProcessor that adds 29 // internal raw stream to request and forwards the request to its ProcessBlock. 30 class RealtimeZslRequestProcessor : public RequestProcessor { 31 public: 32 // device_session_hwl is owned by the caller and must be valid during the 33 // lifetime of this RealtimeZslRequestProcessor. 34 static std::unique_ptr<RealtimeZslRequestProcessor> Create( 35 CameraDeviceSessionHwl* device_session_hwl, 36 android_pixel_format_t pixel_format); 37 38 virtual ~RealtimeZslRequestProcessor() = default; 39 40 // Override functions of RequestProcessor start. 41 // RealtimeZslRequestProcessor will configure all streams in stream_config. 42 // And register one internal raw stream 43 status_t ConfigureStreams( 44 InternalStreamManager* internal_stream_manager, 45 const StreamConfiguration& stream_config, 46 StreamConfiguration* process_block_stream_config) override; 47 48 // Set the realtime process block for sending requests later. 49 status_t SetProcessBlock(std::unique_ptr<ProcessBlock> process_block) override; 50 51 // Add one additional RAW output to capture request 52 // And forwards the capture request to realtime process 53 status_t ProcessRequest(const CaptureRequest& request) override; 54 55 status_t Flush() override; 56 // Override functions of RequestProcessor end. 57 58 protected: RealtimeZslRequestProcessor(android_pixel_format_t pixel_format,CameraDeviceSessionHwl * device_session_hwl)59 RealtimeZslRequestProcessor(android_pixel_format_t pixel_format, 60 CameraDeviceSessionHwl* device_session_hwl) 61 : pixel_format_(pixel_format), 62 device_session_hwl_(device_session_hwl), 63 is_hdrplus_zsl_enabled_(pixel_format == HAL_PIXEL_FORMAT_RAW10){}; 64 65 private: 66 status_t Initialize(CameraDeviceSessionHwl* device_session_hwl); 67 std::shared_mutex process_block_lock_; 68 69 // Protected by process_block_lock_. 70 std::unique_ptr<ProcessBlock> process_block_; 71 72 InternalStreamManager* internal_stream_manager_ = nullptr; 73 android_pixel_format_t pixel_format_; 74 CameraDeviceSessionHwl* device_session_hwl_ = nullptr; 75 bool preview_intent_seen_ = false; 76 int32_t stream_id_ = -1; 77 uint32_t active_array_width_ = 0; 78 uint32_t active_array_height_ = 0; 79 80 HdrMode hdr_mode_ = HdrMode::kHdrplusMode; 81 82 // If HDR+ ZSL is enabled. 83 bool is_hdrplus_zsl_enabled_ = false; 84 }; 85 86 } // namespace google_camera_hal 87 } // namespace android 88 89 #endif // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_REQUEST_PROCESSOR_H_ 90