1 /* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2019 Intel Corporation. All rights reserved.
4 *
5 * Author: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
6 */
7
8 #ifndef __SOF_PROBE_PROBE_H__
9 #define __SOF_PROBE_PROBE_H__
10
11 #if CONFIG_PROBE
12
13 #include <ipc/probe.h>
14
15 /**
16 * A buffer of logging data is available for processing.
17 */
18 typedef void(*probe_logging_hook_t)(uint8_t *buffer, size_t length);
19
20 /**
21 * @brief Initialize the probe logging backend.
22 *
23 * @param hook Function is called when new logging data is written
24 * out by the logger.
25 */
26 void probe_logging_init(probe_logging_hook_t hook);
27
28 /*
29 * \brief Initialize probes subsystem
30 *
31 * param[in,optional] extraction_probe_dma - DMA associated with extraction
32 * In case extraction_probe_dma is NULL, extraction probes
33 * are unavailable.
34 */
35 int probe_init(const struct probe_dma *extraction_probe_dma);
36
37 /*
38 * \brief Deinitialize probes subsystem.
39 *
40 * Detach extraction DMA if was enabled. Return -EINVAL in case some probes
41 * are still in use.
42 */
43 int probe_deinit(void);
44
45 /*
46 * \brief Setup injection DMAs for probes.
47 *
48 * param[in] count - number of DMAs configured during this call
49 * param[in] probe_dma - Array of size 'count' with configuration data for DMAs
50 */
51 int probe_dma_add(uint32_t count, const struct probe_dma *probe_dma);
52
53 /*
54 * \brief Get info about connected injection DMAs
55 *
56 * param[in,out] data - reply to write data to
57 * param[in] max_size - maximum number of bytes available in data
58 */
59 int probe_dma_info(struct sof_ipc_probe_info_params *data, uint32_t max_size);
60
61 /*
62 * \brief Remove injection DMAs
63 *
64 * param[in] count - number of DMAs removed during this call
65 * param[in] stream_tag - array for size 'count' with stream tags associated
66 * with DMAs to be removed
67 */
68 int probe_dma_remove(uint32_t count, const uint32_t *stream_tag);
69
70 /*
71 * \brief Set probe points
72 *
73 * param[in] count - number of probe points configured this call
74 * param[in] probe - array of size 'count' with configuration of probe points
75 */
76 int probe_point_add(uint32_t count, const struct probe_point *probe);
77
78 /*
79 * \brief Get info about connected probe points
80 *
81 * param[in,out] data - reply to write data to
82 * param[in] max_size - maximum number of bytes available in data
83 */
84 int probe_point_info(struct sof_ipc_probe_info_params *data, uint32_t max_size);
85
86 /*
87 * \brief Remove probe points
88 *
89 * param[in] count - number of probe points removed this call
90 * param[in] buffer_id - array of size 'count' with IDs of buffers to which
91 * probes were attached
92 */
93 int probe_point_remove(uint32_t count, const uint32_t *buffer_id);
94
95 /**
96 * \brief Retrieves probes structure.
97 * \return Pointer to probes structure.
98 */
probe_get(void)99 static inline struct probe_pdata *probe_get(void)
100 {
101 return sof_get()->probe;
102 }
103
104 #endif /* CONFIG_PROBE */
105
106 #endif /* __SOF_PROBE_PROBE_H__ */
107