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 HW_EMULATOR_TORCH_STATE_H 18 #define HW_EMULATOR_TORCH_STATE_H 19 20 #include <hwl_types.h> 21 22 #include <mutex> 23 #include <queue> 24 25 namespace android { 26 27 using android::google_camera_hal::HwlTorchModeStatusChangeFunc; 28 using android::google_camera_hal::TorchMode; 29 30 class EmulatedTorchState { 31 public: EmulatedTorchState(uint32_t camera_id,HwlTorchModeStatusChangeFunc torch_cb)32 EmulatedTorchState(uint32_t camera_id, HwlTorchModeStatusChangeFunc torch_cb) 33 : camera_id_(camera_id), torch_cb_(torch_cb) { 34 } 35 36 status_t SetTorchMode(TorchMode mode); 37 void AcquireFlashHw(); 38 void ReleaseFlashHw(); 39 40 private: 41 std::mutex mutex_; 42 43 uint32_t camera_id_; 44 HwlTorchModeStatusChangeFunc torch_cb_; 45 bool camera_open_ = false; 46 47 EmulatedTorchState(const EmulatedTorchState&) = delete; 48 EmulatedTorchState& operator=(const EmulatedTorchState&) = delete; 49 }; 50 51 } // namespace android 52 53 #endif 54