• 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( __MONITOR_FSM_H__ )
21 #define __MONITOR_FSM_H__
22 
23 
24 
25 #define ISP_HAS_MONITOR_FSM 1
26 
27 #define MONITOR_ALG_FLOW_ARR_SIZE 8
28 
29 typedef enum {
30     MON_ALG_AE_INDEX,
31     MON_ALG_AWB_INDEX,
32     MON_ALG_GAMMA_INDEX,
33     MON_ALG_IRIDIX_INDEX,
34     MON_ALG_INDEX_MAX,
35 } mon_alg_index_t;
36 
37 typedef struct _mon_alg_item_ {
38     uint32_t frame_id_tracking;
39     uint32_t frame_id_alg_state_input;
40     uint32_t frame_id_alg_state_output;
41     uint32_t frame_id_alg_state_apply;
42     uint32_t item_is_using;
43 } mon_alg_item_t;
44 
45 typedef struct _mon_alg_info_ {
46     char *alg_name;
47     mon_alg_item_t alg_state_arr[MONITOR_ALG_FLOW_ARR_SIZE];
48     uint32_t alg_arr_write_pos;
49     uint32_t alg_reset_status;
50 
51     uint32_t mon_alg_frame_count;
52     uint32_t alg_delay_in2out_min;
53     uint32_t alg_delay_in2out_cur;
54     uint32_t alg_delay_in2out_max;
55 
56     uint32_t alg_delay_out2apply_min;
57     uint32_t alg_delay_out2apply_cur;
58     uint32_t alg_delay_out2apply_max;
59 
60     // fpt: algorithom execute N frames per time
61     uint32_t alg_fpt_prev_out_id;
62     uint32_t alg_fpt_min;
63     uint32_t alg_fpt_cur;
64     uint32_t alg_fpt_max;
65 } mon_alg_info_t;
66 
67 typedef struct _mon_err_calibration_info {
68     uint32_t err_cnt_calibration_lut_null;
69     uint32_t err_param_calibration_lut_null_idx;
70 } mon_err_calibration_info_t;
71 
72 typedef struct _mon_err_cmos_info {
73     uint32_t err_cnt_cmos_fs_delay;
74     uint32_t err_cnt_cmos_fe_update_not_in_vb;
75     uint32_t err_cnt_cmos_dgain_update_wrong_timing;
76     uint32_t err_cmos_dgain_update_wrong_timing_diff;
77 } mon_err_cmos_info_t;
78 
79 
80 typedef struct _mon_err_iridix_info {
81     uint32_t err_cnt_iridix_fe_update_not_in_vb;
82 } mon_err_iridix_info_t;
83 
84 typedef struct _monitor_fsm_t monitor_fsm_t;
85 typedef struct _monitor_fsm_t *monitor_fsm_ptr_t;
86 typedef const struct _monitor_fsm_t *monitor_fsm_const_ptr_t;
87 
88 struct _monitor_fsm_t {
89     fsm_common_t cmn;
90 
91     acamera_fsm_mgr_t *p_fsm_mgr;
92     fsm_irq_mask_t mask;
93 
94     mon_err_calibration_info_t mon_info_cali;
95 
96     mon_err_cmos_info_t mon_info_cmos;
97 
98     mon_err_iridix_info_t mon_info_iridix;
99 
100     mon_alg_info_t mon_alg_arr[MON_ALG_INDEX_MAX];
101 };
102 
103 
104 void monitor_initialize( monitor_fsm_ptr_t p_fsm );
105 void monitor_func_calc( monitor_fsm_ptr_t p_fsm );
106 
107 void monitor_fsm_clear( monitor_fsm_ptr_t p_fsm );
108 
109 void monitor_fsm_init( void *fsm, fsm_init_param_t *init_param );
110 
111 int monitor_fsm_set_param( void *fsm, uint32_t param_id, void *input, uint32_t input_size );
112 int monitor_fsm_get_param( void *fsm, uint32_t param_id, void *input, uint32_t input_size, void *output, uint32_t output_size );
113 
114 uint8_t monitor_fsm_process_event( monitor_fsm_ptr_t p_fsm, event_id_t event_id );
115 void monitor_fsm_process_interrupt( monitor_fsm_const_ptr_t p_fsm, uint8_t irq_event );
116 void monitor_request_interrupt( monitor_fsm_ptr_t p_fsm, system_fw_interrupt_mask_t mask );
117 
118 void monitor_handle_error_report( monitor_fsm_ptr_t p_fsm, fsm_param_mon_err_head_t *p_mon_err_head );
119 void monitor_handle_reset_error_report( monitor_fsm_ptr_t p_fsm, uint32_t err_type );
120 void monitor_get_error_report( monitor_fsm_ptr_t p_fsm, uint32_t err_type, uint32_t *err_param );
121 
122 void monitor_handle_alg_flow( monitor_fsm_ptr_t p_fsm, mon_alg_info_t *p_mon_info, fsm_param_mon_alg_flow_t *p_flow );
123 void monitor_get_alg_status( monitor_fsm_ptr_t p_fsm, mon_alg_info_t *p_mon_info, uint32_t status_type, uint32_t *status );
124 void monitor_set_alg_status( monitor_fsm_ptr_t p_fsm, mon_alg_info_t *p_mon_info, fsm_param_mon_status_head_t *p_status );
125 
126 #endif /* __MONITOR_FSM_H__ */
127