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 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
9 
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13 more details.
14 */
15 
16 #ifndef __IA_CSS_TIMER_H
17 #define __IA_CSS_TIMER_H
18 
19 /* @file
20  * Timer interface definitions
21  */
22 #include <type_support.h>		/* for uint32_t */
23 #include "ia_css_err.h"
24 
25 /* @brief timer reading definition */
26 typedef u32 clock_value_t;
27 
28 /* @brief 32 bit clock tick,(timestamp based on timer-value of CSS-internal timer)*/
29 struct ia_css_clock_tick {
30 	clock_value_t ticks; /** measured time in ticks.*/
31 };
32 
33 /* @brief TIMER event codes */
34 enum ia_css_tm_event {
35 	IA_CSS_TM_EVENT_AFTER_INIT,
36 	/** Timer Event after Initialization */
37 	IA_CSS_TM_EVENT_MAIN_END,
38 	/** Timer Event after end of Main */
39 	IA_CSS_TM_EVENT_THREAD_START,
40 	/** Timer Event after thread start */
41 	IA_CSS_TM_EVENT_FRAME_PROC_START,
42 	/** Timer Event after Frame Process Start */
43 	IA_CSS_TM_EVENT_FRAME_PROC_END
44 	/** Timer Event after Frame Process End */
45 };
46 
47 /* @brief code measurement common struct */
48 struct ia_css_time_meas {
49 	clock_value_t	start_timer_value;	/** measured time in ticks */
50 	clock_value_t	end_timer_value;	/** measured time in ticks */
51 };
52 
53 /**@brief SIZE_OF_IA_CSS_CLOCK_TICK_STRUCT checks to ensure correct alignment for struct ia_css_clock_tick. */
54 #define SIZE_OF_IA_CSS_CLOCK_TICK_STRUCT sizeof(clock_value_t)
55 /* @brief checks to ensure correct alignment for ia_css_time_meas. */
56 #define SIZE_OF_IA_CSS_TIME_MEAS_STRUCT (sizeof(clock_value_t) \
57 					+ sizeof(clock_value_t))
58 
59 /* @brief API to fetch timer count directly
60 *
61 * @param curr_ts [out] measured count value
62 * @return 0 if success
63 *
64 */
65 int
66 ia_css_timer_get_current_tick(
67     struct ia_css_clock_tick *curr_ts);
68 
69 #endif  /* __IA_CSS_TIMER_H */
70