• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 using android::google_camera_hal::TorchModeStatus;
30 
31 class EmulatedTorchState {
32  public:
EmulatedTorchState(uint32_t camera_id,HwlTorchModeStatusChangeFunc torch_cb)33   EmulatedTorchState(uint32_t camera_id, HwlTorchModeStatusChangeFunc torch_cb)
34       : camera_id_(camera_id), torch_cb_(torch_cb) {
35   }
36 
37   status_t SetTorchMode(TorchMode mode);
38   status_t TurnOnTorchWithStrengthLevel(int32_t torch_strength);
39 
40   void AcquireFlashHw();
41   void ReleaseFlashHw();
42   int32_t GetTorchStrengthLevel();
43   void InitializeTorchDefaultLevel(int32_t default_level);
44   void InitializeSupportTorchStrengthLevel(bool is_torch_strength_control_supported);
45 
46  private:
47   std::mutex mutex_;
48 
49   uint32_t camera_id_;
50   HwlTorchModeStatusChangeFunc torch_cb_;
51   bool camera_open_ = false;
52   TorchModeStatus torch_status_;
53   int32_t new_torch_strength_level_ = 0;
54   bool support_torch_strength_control_ = false;
55   int32_t default_level_ = 0;
56 
57   EmulatedTorchState(const EmulatedTorchState&) = delete;
58   EmulatedTorchState& operator=(const EmulatedTorchState&) = delete;
59 };
60 
61 }  // namespace android
62 
63 #endif
64