1 /* SPDX-License-Identifier: GPL-2.0 */
2 /**
3 Support for Intel Camera Imaging ISP subsystem.
4 Copyright (c) 2010 - 2015, Intel Corporation.
5 
6 */
7 
8 #ifndef __IA_CSS_TIMER_H
9 #define __IA_CSS_TIMER_H
10 
11 /* @file
12  * Timer interface definitions
13  */
14 #include <type_support.h>		/* for uint32_t */
15 #include "ia_css_err.h"
16 
17 /* @brief timer reading definition */
18 typedef u32 clock_value_t;
19 
20 /* @brief 32 bit clock tick,(timestamp based on timer-value of CSS-internal timer)*/
21 struct ia_css_clock_tick {
22 	clock_value_t ticks; /** measured time in ticks.*/
23 };
24 
25 /* @brief TIMER event codes */
26 enum ia_css_tm_event {
27 	IA_CSS_TM_EVENT_AFTER_INIT,
28 	/** Timer Event after Initialization */
29 	IA_CSS_TM_EVENT_MAIN_END,
30 	/** Timer Event after end of Main */
31 	IA_CSS_TM_EVENT_THREAD_START,
32 	/** Timer Event after thread start */
33 	IA_CSS_TM_EVENT_FRAME_PROC_START,
34 	/** Timer Event after Frame Process Start */
35 	IA_CSS_TM_EVENT_FRAME_PROC_END
36 	/** Timer Event after Frame Process End */
37 };
38 
39 /* @brief code measurement common struct */
40 struct ia_css_time_meas {
41 	clock_value_t	start_timer_value;	/** measured time in ticks */
42 	clock_value_t	end_timer_value;	/** measured time in ticks */
43 };
44 
45 /**@brief SIZE_OF_IA_CSS_CLOCK_TICK_STRUCT checks to ensure correct alignment for struct ia_css_clock_tick. */
46 #define SIZE_OF_IA_CSS_CLOCK_TICK_STRUCT sizeof(clock_value_t)
47 /* @brief checks to ensure correct alignment for ia_css_time_meas. */
48 #define SIZE_OF_IA_CSS_TIME_MEAS_STRUCT (sizeof(clock_value_t) \
49 					+ sizeof(clock_value_t))
50 
51 /* @brief API to fetch timer count directly
52 *
53 * @param curr_ts [out] measured count value
54 * @return 0 if success
55 *
56 */
57 int
58 ia_css_timer_get_current_tick(
59     struct ia_css_clock_tick *curr_ts);
60 
61 #endif  /* __IA_CSS_TIMER_H */
62