• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 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_EVENT_PUBLIC_H
17 #define __IA_CSS_EVENT_PUBLIC_H
18 
19 /* @file
20  * This file contains CSS-API events functionality
21  */
22 
23 #include <type_support.h>	/* uint8_t */
24 #include <ia_css_err.h>		/* ia_css_err */
25 #include <ia_css_types.h>	/* ia_css_pipe */
26 #include <ia_css_timer.h>	/* ia_css_timer */
27 
28 /* The event type, distinguishes the kind of events that
29  * can are generated by the CSS system.
30  *
31  * !!!IMPORTANT!!! KEEP THE FOLLOWING IN SYNC:
32  * 1) "enum ia_css_event_type"					(ia_css_event_public.h)
33  * 2) "enum sh_css_sp_event_type"				(sh_css_internal.h)
34  * 3) "enum ia_css_event_type event_id_2_event_mask"		(event_handler.sp.c)
35  * 4) "enum ia_css_event_type convert_event_sp_to_host_domain"	(sh_css.c)
36  */
37 enum ia_css_event_type {
38 	IA_CSS_EVENT_TYPE_OUTPUT_FRAME_DONE		= 1 << 0,
39 	/** Output frame ready. */
40 	IA_CSS_EVENT_TYPE_SECOND_OUTPUT_FRAME_DONE	= 1 << 1,
41 	/** Second output frame ready. */
42 	IA_CSS_EVENT_TYPE_VF_OUTPUT_FRAME_DONE		= 1 << 2,
43 	/** Viewfinder Output frame ready. */
44 	IA_CSS_EVENT_TYPE_SECOND_VF_OUTPUT_FRAME_DONE	= 1 << 3,
45 	/** Second viewfinder Output frame ready. */
46 	IA_CSS_EVENT_TYPE_3A_STATISTICS_DONE		= 1 << 4,
47 	/** Indication that 3A statistics are available. */
48 	IA_CSS_EVENT_TYPE_DIS_STATISTICS_DONE		= 1 << 5,
49 	/** Indication that DIS statistics are available. */
50 	IA_CSS_EVENT_TYPE_PIPELINE_DONE			= 1 << 6,
51 	/** Pipeline Done event, sent after last pipeline stage. */
52 	IA_CSS_EVENT_TYPE_FRAME_TAGGED			= 1 << 7,
53 	/** Frame tagged. */
54 	IA_CSS_EVENT_TYPE_INPUT_FRAME_DONE		= 1 << 8,
55 	/** Input frame ready. */
56 	IA_CSS_EVENT_TYPE_METADATA_DONE			= 1 << 9,
57 	/** Metadata ready. */
58 	IA_CSS_EVENT_TYPE_LACE_STATISTICS_DONE		= 1 << 10,
59 	/** Indication that LACE statistics are available. */
60 	IA_CSS_EVENT_TYPE_ACC_STAGE_COMPLETE		= 1 << 11,
61 	/** Extension stage complete. */
62 	IA_CSS_EVENT_TYPE_TIMER				= 1 << 12,
63 	/** Timer event for measuring the SP side latencies. It contains the
64 	     32-bit timer value from the SP */
65 	IA_CSS_EVENT_TYPE_PORT_EOF			= 1 << 13,
66 	/** End Of Frame event, sent when in buffered sensor mode. */
67 	IA_CSS_EVENT_TYPE_FW_WARNING			= 1 << 14,
68 	/** Performance warning encounter by FW */
69 	IA_CSS_EVENT_TYPE_FW_ASSERT			= 1 << 15,
70 	/** Assertion hit by FW */
71 };
72 
73 #define IA_CSS_EVENT_TYPE_NONE 0
74 
75 /* IA_CSS_EVENT_TYPE_ALL is a mask for all pipe related events.
76  * The other events (such as PORT_EOF) cannot be enabled/disabled
77  * and are hence excluded from this macro.
78  */
79 #define IA_CSS_EVENT_TYPE_ALL \
80 	(IA_CSS_EVENT_TYPE_OUTPUT_FRAME_DONE		| \
81 	 IA_CSS_EVENT_TYPE_SECOND_OUTPUT_FRAME_DONE	| \
82 	 IA_CSS_EVENT_TYPE_VF_OUTPUT_FRAME_DONE		| \
83 	 IA_CSS_EVENT_TYPE_SECOND_VF_OUTPUT_FRAME_DONE	| \
84 	 IA_CSS_EVENT_TYPE_3A_STATISTICS_DONE		| \
85 	 IA_CSS_EVENT_TYPE_DIS_STATISTICS_DONE		| \
86 	 IA_CSS_EVENT_TYPE_PIPELINE_DONE		| \
87 	 IA_CSS_EVENT_TYPE_FRAME_TAGGED			| \
88 	 IA_CSS_EVENT_TYPE_INPUT_FRAME_DONE		| \
89 	 IA_CSS_EVENT_TYPE_METADATA_DONE		| \
90 	 IA_CSS_EVENT_TYPE_LACE_STATISTICS_DONE		| \
91 	 IA_CSS_EVENT_TYPE_ACC_STAGE_COMPLETE)
92 
93 /* The event struct, container for the event type and its related values.
94  * Depending on the event type, either pipe or port will be filled.
95  * Pipeline related events (like buffer/frame events) will return a valid and filled pipe handle.
96  * For non pipeline related events (but i.e. stream specific, like EOF event), the port will be
97  * filled.
98  */
99 struct ia_css_event {
100 	struct ia_css_pipe    *pipe;
101 	/** Pipe handle on which event happened, NULL for non pipe related
102 	     events. */
103 	enum ia_css_event_type type;
104 	/** Type of Event, always valid/filled. */
105 	u8                port;
106 	/** Port number for EOF event (not valid for other events). */
107 	u8                exp_id;
108 	/** Exposure id for EOF/FRAME_TAGGED/FW_WARNING event (not valid for other events)
109 	     The exposure ID is unique only within a logical stream and it is
110 	     only generated on systems that have an input system (such as 2400
111 	     and 2401).
112 	     Most outputs produced by the CSS are tagged with an exposure ID.
113 	     This allows users of the CSS API to keep track of which buffer
114 	     was generated from which sensor output frame. This includes:
115 	     EOF event, output frames, 3A statistics, DVS statistics and
116 	     sensor metadata.
117 	     Exposure IDs start at IA_CSS_MIN_EXPOSURE_ID, increment by one
118 	     until IA_CSS_MAX_EXPOSURE_ID is reached, after that they wrap
119 	     around to IA_CSS_MIN_EXPOSURE_ID again.
120 	     Note that in case frames are dropped, this will not be reflected
121 	     in the exposure IDs. Therefor applications should not use this
122 	     to detect frame drops. */
123 	u32               fw_handle;
124 	/** Firmware Handle for ACC_STAGE_COMPLETE event (not valid for other
125 	     events). */
126 	enum ia_css_fw_warning fw_warning;
127 	/** Firmware warning code, only for WARNING events. */
128 	u8                fw_assert_module_id;
129 	/** Firmware module id, only for ASSERT events, should be logged by driver. */
130 	u16               fw_assert_line_no;
131 	/** Firmware line number, only for ASSERT events, should be logged by driver. */
132 	clock_value_t	       timer_data;
133 	/** For storing the full 32-bit of the timer value. Valid only for TIMER
134 	     event */
135 	u8                timer_code;
136 	/** For storing the code of the TIMER event. Valid only for
137 	     TIMER event */
138 	u8                timer_subcode;
139 	/** For storing the subcode of the TIMER event. Valid only
140 	     for TIMER event */
141 };
142 
143 /* @brief Dequeue a PSYS event from the CSS system.
144  *
145  * @param[out]	event   Pointer to the event struct which will be filled by
146  *                      this function if an event is available.
147  * @return		-ENODATA if no events are
148  *			available or
149  *			0 otherwise.
150  *
151  * This function dequeues an event from the PSYS event queue. The queue is
152  * between the Host CPU and the CSS system. This function can be
153  * called after an interrupt has been generated that signalled that a new event
154  * was available and can be used in a polling-like situation where the NO_EVENT
155  * return value is used to determine whether an event was available or not.
156  */
157 int
158 ia_css_dequeue_psys_event(struct ia_css_event *event);
159 
160 /* @brief Dequeue an event from the CSS system.
161  *
162  * @param[out]	event   Pointer to the event struct which will be filled by
163  *                      this function if an event is available.
164  * @return		-ENODATA if no events are
165  *			available or
166  *			0 otherwise.
167  *
168  * deprecated{Use ia_css_dequeue_psys_event instead}.
169  * Unless the isys event queue is explicitly enabled, this function will
170  * dequeue both isys (EOF) and psys events (all others).
171  */
172 int
173 ia_css_dequeue_event(struct ia_css_event *event);
174 
175 /* @brief Dequeue an ISYS event from the CSS system.
176  *
177  * @param[out]	event   Pointer to the event struct which will be filled by
178  *                      this function if an event is available.
179  * @return		-ENODATA if no events are
180  *			available or
181  *			0 otherwise.
182  *
183  * This function dequeues an event from the ISYS event queue. The queue is
184  * between host and the CSS system.
185  * Unlike the ia_css_dequeue_event() function, this function can be called
186  * directly from an interrupt service routine (ISR) and it is safe to call
187  * this function in parallel with other CSS API functions (but only one
188  * call to this function should be in flight at any point in time).
189  *
190  * The reason for having the ISYS events separate is to prevent them from
191  * incurring additional latency due to locks being held by other CSS API
192  * functions.
193  */
194 int
195 ia_css_dequeue_isys_event(struct ia_css_event *event);
196 
197 #endif /* __IA_CSS_EVENT_PUBLIC_H */
198