• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 *
3 * SPDX-License-Identifier: GPL-2.0
4 *
5 * Copyright (C) 2011-2018 ARM or its affiliates
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19 
20 #if !defined( __AF_FSM_H__ )
21 #define __AF_FSM_H__
22 
23 
24 
25 typedef struct _AF_fsm_t AF_fsm_t;
26 typedef struct _AF_fsm_t *AF_fsm_ptr_t;
27 typedef const struct _AF_fsm_t *AF_fsm_const_ptr_t;
28 
29 #define ISP_HAS_AF_FSM 1
30 #include "acamera_isp_config.h"
31 #include "acamera_lens_api.h"
32 #include "acamera_isp_core_nomem_settings.h"
33 
34 #define ISP_HAS_AF_MANUAL_FSM 1
35 #define AF_ZONES_COUNT_MAX ( ISP_METERING_ZONES_MAX_V * ISP_METERING_ZONES_MAX_H )
36 
37 
38 #define AF_SPOT_IGNORE_NUM 1
39 #define AF_CALIBRATION_BOUNDARIES 1
40 
41 
42 typedef struct _af_lms_param_t {
43     uint32_t pos_min_down;
44     uint32_t pos_min;
45     uint32_t pos_min_up;
46     uint32_t pos_inf_down;
47     uint32_t pos_inf;
48     uint32_t pos_inf_up;
49     uint32_t pos_macro_down;
50     uint32_t pos_macro;
51     uint32_t pos_macro_up;
52     uint32_t pos_max_down;
53     uint32_t pos_max;
54     uint32_t pos_max_up;
55     uint32_t fast_search_positions;
56     uint32_t skip_frames_init;
57     uint32_t skip_frames_move;
58     uint32_t dynamic_range_th;
59     uint32_t spot_tolerance;
60     uint32_t exit_th;
61     uint32_t caf_trigger_th;
62     uint32_t caf_stable_th;
63     uint32_t print_debug;
64 } af_lms_param_t;
65 
66 
67 void AF_init( AF_fsm_ptr_t p_fsm );
68 void AF_deinit( AF_fsm_ptr_t p_fsm );
69 void AF_request_irq( AF_fsm_ptr_t p_fsm );
70 void af_notify_status( AF_fsm_ptr_t p_fsm );
71 
72 struct _AF_fsm_t {
73     fsm_common_t cmn;
74 
75     acamera_fsm_mgr_t *p_fsm_mgr;
76     fsm_irq_mask_t mask;
77     uint32_t zone_raw_statistic[AF_ZONES_COUNT_MAX][2];
78     uint8_t *zone_weight;
79     uint64_t *zone_process_statistic;
80     uint32_t *zone_process_reliablility;
81     uint32_t pos_min;
82     uint32_t pos_inf;
83     uint32_t pos_macro;
84     uint32_t pos_max;
85     uint32_t def_pos_min;
86     uint32_t def_pos_inf;
87     uint32_t def_pos_macro;
88     uint32_t def_pos_max;
89     uint32_t def_pos_min_up;
90     uint32_t def_pos_inf_up;
91     uint32_t def_pos_macro_up;
92     uint32_t def_pos_max_up;
93     uint32_t def_pos_min_down;
94     uint32_t def_pos_inf_down;
95     uint32_t def_pos_macro_down;
96     uint32_t def_pos_max_down;
97     uint8_t skip_frame;
98 
99     uint8_t frame_num;
100     uint32_t mode;
101     uint32_t pos_manual;
102     uint32_t new_pos;
103     uint32_t roi;
104     int32_t lens_driver_ok;
105     uint32_t roi_api;
106     uint32_t frame_number_from_start;
107     uint32_t last_position;
108     uint32_t last_pos_done;
109     int32_t new_last_sharp;
110     int32_t last_sharp_done;
111     void *lens_ctx;
112     lens_control_t lens_ctrl;
113     uint8_t frame_skip_cnt;
114     uint8_t frame_skip_start;
115 };
116 
117 
118 void AF_fsm_clear( AF_fsm_ptr_t p_fsm );
119 
120 void AF_fsm_init( void *fsm, fsm_init_param_t *init_param );
121 int AF_fsm_set_param( void *fsm, uint32_t param_id, void *input, uint32_t input_size );
122 int AF_fsm_get_param( void *fsm, uint32_t param_id, void *input, uint32_t input_size, void *output, uint32_t output_size );
123 
124 uint8_t AF_fsm_process_event( AF_fsm_ptr_t p_fsm, event_id_t event_id );
125 
126 void AF_fsm_process_interrupt( AF_fsm_const_ptr_t p_fsm, uint8_t irq_event );
127 
128 void AF_request_interrupt( AF_fsm_ptr_t p_fsm, system_fw_interrupt_mask_t mask );
129 
130 #endif /* __AF_FSM_H__ */
131