1 /*
2  * Copyright (C) 2023 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 #pragma once
18 
19 #include <chrono>
20 #include <utility>
21 #include <system/camera_metadata.h>
22 
23 namespace android {
24 namespace hardware {
25 namespace camera {
26 namespace provider {
27 namespace implementation {
28 namespace hw {
29 
30 struct AFStateMachine {
31     AFStateMachine(int afDurationMs, float focusedDistance, float unfocusedDistance);
32 
33     std::pair<camera_metadata_enum_android_control_af_state_t, float>
34         operator()(camera_metadata_enum_android_control_af_mode_t,
35                    camera_metadata_enum_android_control_af_trigger_t);
36 
37     std::pair<camera_metadata_enum_android_control_af_state_t, float> operator()();
38     std::pair<camera_metadata_enum_android_control_af_state_t, float> doAF();
39 
40     camera_metadata_enum_android_control_af_state_t state = ANDROID_CONTROL_AF_STATE_INACTIVE;
41     std::chrono::steady_clock::time_point afLockedT;
42     std::chrono::steady_clock::duration afDuration;
43     float focusedDistance;
44     float unfocusedDistance;
45 };
46 
47 }  // namespace hw
48 }  // namespace implementation
49 }  // namespace provider
50 }  // namespace camera
51 }  // namespace hardware
52 }  // namespace android
53