]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_irq.h
staging/atomisp: Add support for the Intel IPU v2
[mirror_ubuntu-hirsute-kernel.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / ia_css_irq.h
1 /*
2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 */
14
15 #ifndef __IA_CSS_IRQ_H
16 #define __IA_CSS_IRQ_H
17
18 /** @file
19 * This file contains information for Interrupts/IRQs from CSS
20 */
21
22 #include "ia_css_err.h"
23 #include "ia_css_pipe_public.h"
24 #include "ia_css_input_port.h"
25
26 /** Interrupt types, these enumerate all supported interrupt types.
27 */
28 enum ia_css_irq_type {
29 IA_CSS_IRQ_TYPE_EDGE, /**< Edge (level) sensitive interrupt */
30 IA_CSS_IRQ_TYPE_PULSE /**< Pulse-shaped interrupt */
31 };
32
33 /** Interrupt request type.
34 * When the CSS hardware generates an interrupt, a function in this API
35 * needs to be called to retrieve information about the interrupt.
36 * This interrupt type is part of this information and indicates what
37 * type of information the interrupt signals.
38 *
39 * Note that one interrupt can carry multiple interrupt types. For
40 * example: the online video ISP will generate only 2 interrupts, one to
41 * signal that the statistics (3a and DIS) are ready and one to signal
42 * that all output frames are done (output and viewfinder).
43 *
44 * DEPRECATED, this interface is not portable it should only define user
45 * (SW) interrupts
46 */
47 enum ia_css_irq_info {
48 IA_CSS_IRQ_INFO_CSS_RECEIVER_ERROR = 1 << 0,
49 /**< the css receiver has encountered an error */
50 IA_CSS_IRQ_INFO_CSS_RECEIVER_FIFO_OVERFLOW = 1 << 1,
51 /**< the FIFO in the csi receiver has overflown */
52 IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF = 1 << 2,
53 /**< the css receiver received the start of frame */
54 IA_CSS_IRQ_INFO_CSS_RECEIVER_EOF = 1 << 3,
55 /**< the css receiver received the end of frame */
56 IA_CSS_IRQ_INFO_CSS_RECEIVER_SOL = 1 << 4,
57 /**< the css receiver received the start of line */
58 IA_CSS_IRQ_INFO_PSYS_EVENTS_READY = 1 << 5,
59 /**< One or more events are available in the PSYS event queue */
60 IA_CSS_IRQ_INFO_EVENTS_READY = IA_CSS_IRQ_INFO_PSYS_EVENTS_READY,
61 /**< deprecated{obsolete version of IA_CSS_IRQ_INFO_PSYS_EVENTS_READY,
62 * same functionality.} */
63 IA_CSS_IRQ_INFO_CSS_RECEIVER_EOL = 1 << 6,
64 /**< the css receiver received the end of line */
65 IA_CSS_IRQ_INFO_CSS_RECEIVER_SIDEBAND_CHANGED = 1 << 7,
66 /**< the css receiver received a change in side band signals */
67 IA_CSS_IRQ_INFO_CSS_RECEIVER_GEN_SHORT_0 = 1 << 8,
68 /**< generic short packets (0) */
69 IA_CSS_IRQ_INFO_CSS_RECEIVER_GEN_SHORT_1 = 1 << 9,
70 /**< generic short packets (1) */
71 IA_CSS_IRQ_INFO_IF_PRIM_ERROR = 1 << 10,
72 /**< the primary input formatter (A) has encountered an error */
73 IA_CSS_IRQ_INFO_IF_PRIM_B_ERROR = 1 << 11,
74 /**< the primary input formatter (B) has encountered an error */
75 IA_CSS_IRQ_INFO_IF_SEC_ERROR = 1 << 12,
76 /**< the secondary input formatter has encountered an error */
77 IA_CSS_IRQ_INFO_STREAM_TO_MEM_ERROR = 1 << 13,
78 /**< the stream-to-memory device has encountered an error */
79 IA_CSS_IRQ_INFO_SW_0 = 1 << 14,
80 /**< software interrupt 0 */
81 IA_CSS_IRQ_INFO_SW_1 = 1 << 15,
82 /**< software interrupt 1 */
83 IA_CSS_IRQ_INFO_SW_2 = 1 << 16,
84 /**< software interrupt 2 */
85 IA_CSS_IRQ_INFO_ISP_BINARY_STATISTICS_READY = 1 << 17,
86 /**< ISP binary statistics are ready */
87 IA_CSS_IRQ_INFO_INPUT_SYSTEM_ERROR = 1 << 18,
88 /**< the input system in in error */
89 IA_CSS_IRQ_INFO_IF_ERROR = 1 << 19,
90 /**< the input formatter in in error */
91 IA_CSS_IRQ_INFO_DMA_ERROR = 1 << 20,
92 /**< the dma in in error */
93 IA_CSS_IRQ_INFO_ISYS_EVENTS_READY = 1 << 21,
94 /**< end-of-frame events are ready in the isys_event queue */
95 };
96
97 /** CSS receiver error types. Whenever the CSS receiver has encountered
98 * an error, this enumeration is used to indicate which errors have occurred.
99 *
100 * Note that multiple error flags can be enabled at once and that this is in
101 * fact common (whenever an error occurs, it usually results in multiple
102 * errors).
103 *
104 * DEPRECATED: This interface is not portable, different systems have
105 * different receiver types, or possibly none in case of tests systems.
106 */
107 enum ia_css_rx_irq_info {
108 IA_CSS_RX_IRQ_INFO_BUFFER_OVERRUN = 1U << 0, /**< buffer overrun */
109 IA_CSS_RX_IRQ_INFO_ENTER_SLEEP_MODE = 1U << 1, /**< entering sleep mode */
110 IA_CSS_RX_IRQ_INFO_EXIT_SLEEP_MODE = 1U << 2, /**< exited sleep mode */
111 IA_CSS_RX_IRQ_INFO_ECC_CORRECTED = 1U << 3, /**< ECC corrected */
112 IA_CSS_RX_IRQ_INFO_ERR_SOT = 1U << 4,
113 /**< Start of transmission */
114 IA_CSS_RX_IRQ_INFO_ERR_SOT_SYNC = 1U << 5, /**< SOT sync (??) */
115 IA_CSS_RX_IRQ_INFO_ERR_CONTROL = 1U << 6, /**< Control (??) */
116 IA_CSS_RX_IRQ_INFO_ERR_ECC_DOUBLE = 1U << 7, /**< Double ECC */
117 IA_CSS_RX_IRQ_INFO_ERR_CRC = 1U << 8, /**< CRC error */
118 IA_CSS_RX_IRQ_INFO_ERR_UNKNOWN_ID = 1U << 9, /**< Unknown ID */
119 IA_CSS_RX_IRQ_INFO_ERR_FRAME_SYNC = 1U << 10,/**< Frame sync error */
120 IA_CSS_RX_IRQ_INFO_ERR_FRAME_DATA = 1U << 11,/**< Frame data error */
121 IA_CSS_RX_IRQ_INFO_ERR_DATA_TIMEOUT = 1U << 12,/**< Timeout occurred */
122 IA_CSS_RX_IRQ_INFO_ERR_UNKNOWN_ESC = 1U << 13,/**< Unknown escape seq. */
123 IA_CSS_RX_IRQ_INFO_ERR_LINE_SYNC = 1U << 14,/**< Line Sync error */
124 IA_CSS_RX_IRQ_INFO_INIT_TIMEOUT = 1U << 15,
125 };
126
127 /** Interrupt info structure. This structure contains information about an
128 * interrupt. This needs to be used after an interrupt is received on the IA
129 * to perform the correct action.
130 */
131 struct ia_css_irq {
132 enum ia_css_irq_info type; /**< Interrupt type. */
133 unsigned int sw_irq_0_val; /**< In case of SW interrupt 0, value. */
134 unsigned int sw_irq_1_val; /**< In case of SW interrupt 1, value. */
135 unsigned int sw_irq_2_val; /**< In case of SW interrupt 2, value. */
136 struct ia_css_pipe *pipe;
137 /**< The image pipe that generated the interrupt. */
138 };
139
140 /** @brief Obtain interrupt information.
141 *
142 * @param[out] info Pointer to the interrupt info. The interrupt
143 * information wil be written to this info.
144 * @return If an error is encountered during the interrupt info
145 * and no interrupt could be translated successfully, this
146 * will return IA_CSS_INTERNAL_ERROR. Otherwise
147 * IA_CSS_SUCCESS.
148 *
149 * This function is expected to be executed after an interrupt has been sent
150 * to the IA from the CSS. This function returns information about the interrupt
151 * which is needed by the IA code to properly handle the interrupt. This
152 * information includes the image pipe, buffer type etc.
153 */
154 enum ia_css_err
155 ia_css_irq_translate(unsigned int *info);
156
157 /** @brief Get CSI receiver error info.
158 *
159 * @param[out] irq_bits Pointer to the interrupt bits. The interrupt
160 * bits will be written this info.
161 * This will be the error bits that are enabled in the CSI
162 * receiver error register.
163 * @return None
164 *
165 * This function should be used whenever a CSI receiver error interrupt is
166 * generated. It provides the detailed information (bits) on the exact error
167 * that occurred.
168 *
169 *@deprecated {this function is DEPRECATED since it only works on CSI port 1.
170 * Use the function below instead and specify the appropriate port.}
171 */
172 void
173 ia_css_rx_get_irq_info(unsigned int *irq_bits);
174
175 /** @brief Get CSI receiver error info.
176 *
177 * @param[in] port Input port identifier.
178 * @param[out] irq_bits Pointer to the interrupt bits. The interrupt
179 * bits will be written this info.
180 * This will be the error bits that are enabled in the CSI
181 * receiver error register.
182 * @return None
183 *
184 * This function should be used whenever a CSI receiver error interrupt is
185 * generated. It provides the detailed information (bits) on the exact error
186 * that occurred.
187 */
188 void
189 ia_css_rx_port_get_irq_info(enum ia_css_csi2_port port, unsigned int *irq_bits);
190
191 /** @brief Clear CSI receiver error info.
192 *
193 * @param[in] irq_bits The bits that should be cleared from the CSI receiver
194 * interrupt bits register.
195 * @return None
196 *
197 * This function should be called after ia_css_rx_get_irq_info has been called
198 * and the error bits have been interpreted. It is advised to use the return
199 * value of that function as the argument to this function to make sure no new
200 * error bits get overwritten.
201 *
202 * @deprecated{this function is DEPRECATED since it only works on CSI port 1.
203 * Use the function below instead and specify the appropriate port.}
204 */
205 void
206 ia_css_rx_clear_irq_info(unsigned int irq_bits);
207
208 /** @brief Clear CSI receiver error info.
209 *
210 * @param[in] port Input port identifier.
211 * @param[in] irq_bits The bits that should be cleared from the CSI receiver
212 * interrupt bits register.
213 * @return None
214 *
215 * This function should be called after ia_css_rx_get_irq_info has been called
216 * and the error bits have been interpreted. It is advised to use the return
217 * value of that function as the argument to this function to make sure no new
218 * error bits get overwritten.
219 */
220 void
221 ia_css_rx_port_clear_irq_info(enum ia_css_csi2_port port, unsigned int irq_bits);
222
223 /** @brief Enable or disable specific interrupts.
224 *
225 * @param[in] type The interrupt type that will be enabled/disabled.
226 * @param[in] enable enable or disable.
227 * @return Returns IA_CSS_INTERNAL_ERROR if this interrupt
228 * type cannot be enabled/disabled which is true for
229 * CSS internal interrupts. Otherwise returns
230 * IA_CSS_SUCCESS.
231 */
232 enum ia_css_err
233 ia_css_irq_enable(enum ia_css_irq_info type, bool enable);
234
235 #endif /* __IA_CSS_IRQ_H */