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_RESULT_PROCESSOR_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_RESULT_PROCESSOR_H_ 19 20 #include "internal_stream_manager.h" 21 #include "result_processor.h" 22 23 namespace android { 24 namespace google_camera_hal { 25 26 // RealtimeZslResultProcessor implements a ResultProcessor that return filled 27 // raw buffer and matedata to internal stream manager and forwards the results 28 // without raw buffer to its callback functions. 29 class RealtimeZslResultProcessor : public ResultProcessor { 30 public: 31 static std::unique_ptr<RealtimeZslResultProcessor> Create( 32 InternalStreamManager* internal_stream_manager, int32_t stream_id, 33 android_pixel_format_t pixel_format, uint32_t partial_result_count = 1); 34 35 virtual ~RealtimeZslResultProcessor() = default; 36 37 // Override functions of ResultProcessor start. 38 void SetResultCallback(ProcessCaptureResultFunc process_capture_result, 39 NotifyFunc notify) override; 40 41 status_t AddPendingRequests( 42 const std::vector<ProcessBlockRequest>& process_block_requests, 43 const CaptureRequest& remaining_session_request) override; 44 45 // Return filled raw buffer and matedata to internal stream manager 46 // and forwards the results without raw buffer to its callback functions. 47 void ProcessResult(ProcessBlockResult block_result) override; 48 49 void Notify(const ProcessBlockNotifyMessage& block_message) override; 50 51 status_t FlushPendingRequests() override; 52 // Override functions of ResultProcessor end. 53 54 protected: 55 RealtimeZslResultProcessor(InternalStreamManager* internal_stream_manager, 56 int32_t stream_id, 57 android_pixel_format_t pixel_format, 58 uint32_t partial_result_count); 59 60 private: 61 // Save face detect mode for HDR+ 62 void SaveFdForHdrplus(const CaptureRequest& request); 63 // Handle face detect metadata from result for HDR+ 64 status_t HandleFdResultForHdrplus(uint32_t frameNumber, 65 HalCameraMetadata* metadata); 66 // Save lens shading map mode for HDR+ 67 void SaveLsForHdrplus(const CaptureRequest& request); 68 // Handle Lens shading metadata from result for HDR+ 69 status_t HandleLsResultForHdrplus(uint32_t frameNumber, 70 HalCameraMetadata* metadata); 71 std::mutex callback_lock_; 72 73 // The following callbacks must be protected by callback_lock_. 74 ProcessCaptureResultFunc process_capture_result_; 75 NotifyFunc notify_; 76 77 InternalStreamManager* internal_stream_manager_; 78 int32_t stream_id_ = -1; 79 android_pixel_format_t pixel_format_; 80 81 // Current face detect mode set by framework. 82 uint8_t current_face_detect_mode_ = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF; 83 84 std::mutex face_detect_lock_; 85 // Map from frame number to face detect mode requested for that frame by 86 // framework. And requested_face_detect_modes_ is protected by 87 // face_detect_lock_ 88 std::unordered_map<uint32_t, uint8_t> requested_face_detect_modes_; 89 90 // Current lens shading map mode set by framework. 91 uint8_t current_lens_shading_map_mode_ = 92 ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF; 93 94 std::mutex lens_shading_lock_; 95 // Map from frame number to lens shading map mode requested for that frame 96 // by framework. And requested_lens_shading_map_modes_ is protected by 97 // lens_shading_lock_ 98 std::unordered_map<uint32_t, uint8_t> requested_lens_shading_map_modes_; 99 100 // Partial result count reported by HAL 101 uint32_t partial_result_count_; 102 }; 103 104 } // namespace google_camera_hal 105 } // namespace android 106 107 #endif // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_RESULT_PROCESSOR_H_ 108