2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015, Intel Corporation.
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.
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
15 #ifndef _IA_CSS_DEBUG_H_
16 #define _IA_CSS_DEBUG_H_
20 #include <type_support.h>
22 #include "ia_css_types.h"
23 #include "ia_css_binary.h"
24 #include "ia_css_frame_public.h"
25 #include "ia_css_pipe_public.h"
26 #include "ia_css_stream_public.h"
27 #include "ia_css_metadata.h"
28 #include "sh_css_internal.h"
30 #if defined(IS_ISP_2500_SYSTEM)
31 #include "ia_css_pipe.h"
35 /* available levels */
36 /*! Level for tracing errors */
37 #define IA_CSS_DEBUG_ERROR 1
38 /*! Level for tracing warnings */
39 #define IA_CSS_DEBUG_WARNING 3
40 /*! Level for tracing debug messages */
41 #define IA_CSS_DEBUG_VERBOSE 5
42 /*! Level for tracing trace messages a.o. ia_css public function calls */
43 #define IA_CSS_DEBUG_TRACE 6
44 /*! Level for tracing trace messages a.o. ia_css private function calls */
45 #define IA_CSS_DEBUG_TRACE_PRIVATE 7
46 /*! Level for tracing parameter messages e.g. in and out params of functions */
47 #define IA_CSS_DEBUG_PARAM 8
48 /*! Level for tracing info messages */
49 #define IA_CSS_DEBUG_INFO 9
50 /* Global variable which controls the verbosity levels of the debug tracing */
51 extern unsigned int ia_css_debug_trace_level
;
53 /*! @brief Enum defining the different isp parameters to dump.
54 * Values can be combined to dump a combination of sets.
56 enum ia_css_debug_enable_param_dump
{
57 IA_CSS_DEBUG_DUMP_FPN
= 1 << 0, /** FPN table */
58 IA_CSS_DEBUG_DUMP_OB
= 1 << 1, /** OB table */
59 IA_CSS_DEBUG_DUMP_SC
= 1 << 2, /** Shading table */
60 IA_CSS_DEBUG_DUMP_WB
= 1 << 3, /** White balance */
61 IA_CSS_DEBUG_DUMP_DP
= 1 << 4, /** Defect Pixel */
62 IA_CSS_DEBUG_DUMP_BNR
= 1 << 5, /** Bayer Noise Reductions */
63 IA_CSS_DEBUG_DUMP_S3A
= 1 << 6, /** 3A Statistics */
64 IA_CSS_DEBUG_DUMP_DE
= 1 << 7, /** De Mosaicing */
65 IA_CSS_DEBUG_DUMP_YNR
= 1 << 8, /** Luma Noise Reduction */
66 IA_CSS_DEBUG_DUMP_CSC
= 1 << 9, /** Color Space Conversion */
67 IA_CSS_DEBUG_DUMP_GC
= 1 << 10, /** Gamma Correction */
68 IA_CSS_DEBUG_DUMP_TNR
= 1 << 11, /** Temporal Noise Reduction */
69 IA_CSS_DEBUG_DUMP_ANR
= 1 << 12, /** Advanced Noise Reduction */
70 IA_CSS_DEBUG_DUMP_CE
= 1 << 13, /** Chroma Enhancement */
71 IA_CSS_DEBUG_DUMP_ALL
= 1 << 14 /** Dump all device parameters */
74 #define IA_CSS_ERROR(fmt, ...) \
75 ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR, \
76 "%s() %d: error: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__)
78 #define IA_CSS_WARNING(fmt, ...) \
79 ia_css_debug_dtrace(IA_CSS_DEBUG_WARNING, \
80 "%s() %d: warning: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__)
82 /* Logging macros for public functions (API functions) */
83 #define IA_CSS_ENTER(fmt, ...) \
84 ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, \
85 "%s(): enter: " fmt "\n", __func__, ##__VA_ARGS__)
87 /* Use this macro for small functions that do not call other functions. */
88 #define IA_CSS_ENTER_LEAVE(fmt, ...) \
89 ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, \
90 "%s(): enter: leave: " fmt "\n", __func__, ##__VA_ARGS__)
92 #define IA_CSS_LEAVE(fmt, ...) \
93 ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, \
94 "%s(): leave: " fmt "\n", __func__, ##__VA_ARGS__)
96 /* Shorthand for returning an enum ia_css_err return value */
97 #define IA_CSS_LEAVE_ERR(__err) \
98 ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, \
99 "%s() %d: leave: return_err=%d\n", __func__, __LINE__, __err)
101 /* Use this macro for logging other than enter/leave.
102 * Note that this macro always uses the PRIVATE logging level.
104 #define IA_CSS_LOG(fmt, ...) \
105 ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, \
106 "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
108 /* Logging macros for non-API functions. These have a lower trace level */
109 #define IA_CSS_ENTER_PRIVATE(fmt, ...) \
110 ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, \
111 "%s(): enter: " fmt "\n", __func__, ##__VA_ARGS__)
113 #define IA_CSS_LEAVE_PRIVATE(fmt, ...) \
114 ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, \
115 "%s(): leave: " fmt "\n", __func__, ##__VA_ARGS__)
117 /* Shorthand for returning an enum ia_css_err return value */
118 #define IA_CSS_LEAVE_ERR_PRIVATE(__err) \
119 ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, \
120 "%s() %d: leave: return_err=%d\n", __func__, __LINE__, __err)
122 /* Use this macro for small functions that do not call other functions. */
123 #define IA_CSS_ENTER_LEAVE_PRIVATE(fmt, ...) \
124 ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, \
125 "%s(): enter: leave: " fmt "\n", __func__, ##__VA_ARGS__)
127 /*! @brief Function for tracing to the provided printf function in the
129 * @param[in] level Level of the message.
130 * @param[in] fmt printf like format string
131 * @param[in] args arguments for the format string
134 ia_css_debug_vdtrace(unsigned int level
, const char *fmt
, va_list args
)
136 if (ia_css_debug_trace_level
>= level
)
137 sh_css_vprint(fmt
, args
);
141 extern void ia_css_debug_dtrace(unsigned int level
, const char *fmt
, ...);
143 /*! @brief Dump sp thread's stack contents
144 * SP thread's stack contents are set to 0xcafecafe. This function dumps the
145 * stack to inspect if the stack's boundaries are compromised.
148 void ia_css_debug_dump_sp_stack_info(void);
150 /*! @brief Function to set the global dtrace verbosity level.
151 * @param[in] trace_level Maximum level of the messages to be traced.
154 void ia_css_debug_set_dtrace_level(
155 const unsigned int trace_level
);
157 /*! @brief Function to get the global dtrace verbosity level.
158 * @return global dtrace verbosity level
160 unsigned int ia_css_debug_get_dtrace_level(void);
162 /*! @brief Dump input formatter state.
163 * Dumps the input formatter state to tracing output.
166 void ia_css_debug_dump_if_state(void);
168 /*! @brief Dump isp hardware state.
169 * Dumps the isp hardware state to tracing output.
172 void ia_css_debug_dump_isp_state(void);
174 /*! @brief Dump sp hardware state.
175 * Dumps the sp hardware state to tracing output.
178 void ia_css_debug_dump_sp_state(void);
181 /*! @brief Dump GAC hardware state.
182 * Dumps the GAC ACB hardware registers. may be useful for
183 * detecting a GAC which got hang.
186 void ia_css_debug_dump_gac_state(void);
189 /*! @brief Dump dma controller state.
190 * Dumps the dma controller state to tracing output.
193 void ia_css_debug_dump_dma_state(void);
195 /*! @brief Dump internal sp software state.
196 * Dumps the sp software state to tracing output.
199 void ia_css_debug_dump_sp_sw_debug_info(void);
201 /*! @brief Dump all related hardware state to the trace output
202 * @param[in] context String to identify context in output.
205 void ia_css_debug_dump_debug_info(
206 const char *context
);
208 #if SP_DEBUG != SP_DEBUG_NONE
209 void ia_css_debug_print_sp_debug_state(
210 const struct sh_css_sp_debug_state
*state
);
213 /*! @brief Dump all related binary info data
214 * @param[in] bi Binary info struct.
217 void ia_css_debug_binary_print(
218 const struct ia_css_binary
*bi
);
220 void ia_css_debug_sp_dump_mipi_fifo_high_water(void);
222 /*! @brief Dump isp gdc fifo state to the trace output
223 * Dumps the isp gdc fifo state to tracing output.
226 void ia_css_debug_dump_isp_gdc_fifo_state(void);
228 /*! @brief Dump dma isp fifo state
229 * Dumps the dma isp fifo state to tracing output.
232 void ia_css_debug_dump_dma_isp_fifo_state(void);
234 /*! @brief Dump dma sp fifo state
235 * Dumps the dma sp fifo state to tracing output.
238 void ia_css_debug_dump_dma_sp_fifo_state(void);
240 /*! \brief Dump pif A isp fifo state
241 * Dumps the primary input formatter state to tracing output.
244 void ia_css_debug_dump_pif_a_isp_fifo_state(void);
246 /*! \brief Dump pif B isp fifo state
247 * Dumps the primary input formatter state to tracing output.
250 void ia_css_debug_dump_pif_b_isp_fifo_state(void);
252 /*! @brief Dump stream-to-memory sp fifo state
253 * Dumps the stream-to-memory block state to tracing output.
256 void ia_css_debug_dump_str2mem_sp_fifo_state(void);
258 /*! @brief Dump isp sp fifo state
259 * Dumps the isp sp fifo state to tracing output.
262 void ia_css_debug_dump_isp_sp_fifo_state(void);
264 /*! @brief Dump all fifo state info to the output
265 * Dumps all fifo state to tracing output.
268 void ia_css_debug_dump_all_fifo_state(void);
270 /*! @brief Dump the rx state to the output
271 * Dumps the rx state to tracing output.
274 void ia_css_debug_dump_rx_state(void);
276 /*! @brief Dump the input system state to the output
277 * Dumps the input system state to tracing output.
280 void ia_css_debug_dump_isys_state(void);
282 /*! @brief Dump the frame info to the trace output
283 * Dumps the frame info to tracing output.
284 * @param[in] frame pointer to struct ia_css_frame
285 * @param[in] descr description output along with the frame info
288 void ia_css_debug_frame_print(
289 const struct ia_css_frame
*frame
,
292 /*! @brief Function to enable sp sleep mode.
293 * Function that enables sp sleep mode
294 * @param[in] mode indicates when to put sp to sleep
297 void ia_css_debug_enable_sp_sleep_mode(enum ia_css_sp_sleep_mode mode
);
299 /*! @brief Function to wake up sp when in sleep mode.
300 * After sp has been put to sleep, use this function to let it continue
304 void ia_css_debug_wake_up_sp(void);
306 /*! @brief Function to dump isp parameters.
307 * Dump isp parameters to tracing output
308 * @param[in] stream pointer to ia_css_stream struct
309 * @param[in] enable flag indicating which parameters to dump.
312 void ia_css_debug_dump_isp_params(struct ia_css_stream
*stream
, unsigned int enable
);
314 /*! @brief Function to dump some sp performance counters.
315 * Dump sp performance counters, currently input system errors.
318 void ia_css_debug_dump_perf_counters(void);
320 #ifdef HAS_WATCHDOG_SP_THREAD_DEBUG
321 void sh_css_dump_thread_wait_info(void);
322 void sh_css_dump_pipe_stage_info(void);
323 void sh_css_dump_pipe_stripe_info(void);
326 void ia_css_debug_dump_isp_binary(void);
328 void sh_css_dump_sp_raw_copy_linecount(bool reduced
);
330 /*! @brief Dump the resolution info to the trace output
331 * Dumps the resolution info to the trace output.
332 * @param[in] res pointer to struct ia_css_resolution
333 * @param[in] label description of resolution output
336 void ia_css_debug_dump_resolution(
337 const struct ia_css_resolution
*res
,
340 /*! @brief Dump the frame info to the trace output
341 * Dumps the frame info to the trace output.
342 * @param[in] info pointer to struct ia_css_frame_info
343 * @param[in] label description of frame_info output
346 void ia_css_debug_dump_frame_info(
347 const struct ia_css_frame_info
*info
,
350 /*! @brief Dump the capture config info to the trace output
351 * Dumps the capture config info to the trace output.
352 * @param[in] config pointer to struct ia_css_capture_config
355 void ia_css_debug_dump_capture_config(
356 const struct ia_css_capture_config
*config
);
358 /*! @brief Dump the pipe extra config info to the trace output
359 * Dumps the pipe extra config info to the trace output.
360 * @param[in] extra_config pointer to struct ia_css_pipe_extra_config
363 void ia_css_debug_dump_pipe_extra_config(
364 const struct ia_css_pipe_extra_config
*extra_config
);
366 /*! @brief Dump the pipe config info to the trace output
367 * Dumps the pipe config info to the trace output.
368 * @param[in] config pointer to struct ia_css_pipe_config
371 void ia_css_debug_dump_pipe_config(
372 const struct ia_css_pipe_config
*config
);
375 /*! @brief Dump the stream config source info to the trace output
376 * Dumps the stream config source info to the trace output.
377 * @param[in] config pointer to struct ia_css_stream_config
380 void ia_css_debug_dump_stream_config_source(
381 const struct ia_css_stream_config
*config
);
383 /*! @brief Dump the mipi buffer config info to the trace output
384 * Dumps the mipi buffer config info to the trace output.
385 * @param[in] config pointer to struct ia_css_mipi_buffer_config
388 void ia_css_debug_dump_mipi_buffer_config(
389 const struct ia_css_mipi_buffer_config
*config
);
391 /*! @brief Dump the metadata config info to the trace output
392 * Dumps the metadata config info to the trace output.
393 * @param[in] config pointer to struct ia_css_metadata_config
396 void ia_css_debug_dump_metadata_config(
397 const struct ia_css_metadata_config
*config
);
399 /*! @brief Dump the stream config info to the trace output
400 * Dumps the stream config info to the trace output.
401 * @param[in] config pointer to struct ia_css_stream_config
402 * @param[in] num_pipes number of pipes for the stream
405 void ia_css_debug_dump_stream_config(
406 const struct ia_css_stream_config
*config
,
409 /*! @brief Dump the state of the SP tagger
410 * Dumps the internal state of the SP tagger
413 void ia_css_debug_tagger_state(void);
416 * @brief Initialize the debug mode.
419 * This API should be called ONLY once in the debug mode.
422 * - true, if it is successful.
423 * - false, otherwise.
425 bool ia_css_debug_mode_init(void);
428 * @brief Disable the DMA channel.
430 * @param[in] dma_ID The ID of the target DMA.
431 * @param[in] channel_id The ID of the target DMA channel.
432 * @param[in] request_type The type of the DMA request.
434 * - "0" indicates the writing request.
435 * - "1" indicates the reading request.
437 * This is part of the DMA API -> dma.h
440 * - true, if it is successful.
441 * - false, otherwise.
443 bool ia_css_debug_mode_disable_dma_channel(
448 * @brief Enable the DMA channel.
450 * @param[in] dma_ID The ID of the target DMA.
451 * @param[in] channel_id The ID of the target DMA channel.
452 * @param[in] request_type The type of the DMA request.
454 * - "0" indicates the writing request.
455 * - "1" indicates the reading request.
458 * - true, if it is successful.
459 * - false, otherwise.
461 bool ia_css_debug_mode_enable_dma_channel(
467 * @brief Dump tracer data.
468 * [Currently support is only for SKC]
473 void ia_css_debug_dump_trace(void);
477 * @brief Program counter dumping (in loop)
479 * @param[in] id The ID of the SP
480 * @param[in] num_of_dumps The number of dumps
485 void ia_css_debug_pc_dump(sp_ID_t id
, unsigned int num_of_dumps
);
487 #if defined(IS_ISP_2500_SYSTEM)
488 /*! @brief Dump all states for ISP hang case.
489 * Dumps the ISP previous and current configurations
490 * GACs status, SP0/1 statuses.
492 * @param[in] pipe The current pipe
496 void ia_css_debug_dump_hang_status(
497 struct ia_css_pipe
*pipe
);
499 /*! @brief External command handler
500 * External command handler
504 void ia_css_debug_ext_command_handler(void);
509 #endif /* _IA_CSS_DEBUG_H_ */