xref: /openbmc/linux/sound/core/pcm_param_trace.h (revision 1a59d1b8)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM snd_pcm
4 
5 #if !defined(_PCM_PARAMS_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _PCM_PARAMS_TRACE_H
7 
8 #include <linux/tracepoint.h>
9 
10 #define HW_PARAM_ENTRY(param) {SNDRV_PCM_HW_PARAM_##param, #param}
11 #define hw_param_labels			\
12 	HW_PARAM_ENTRY(ACCESS),		\
13 	HW_PARAM_ENTRY(FORMAT),		\
14 	HW_PARAM_ENTRY(SUBFORMAT),	\
15 	HW_PARAM_ENTRY(SAMPLE_BITS),	\
16 	HW_PARAM_ENTRY(FRAME_BITS),	\
17 	HW_PARAM_ENTRY(CHANNELS),	\
18 	HW_PARAM_ENTRY(RATE),		\
19 	HW_PARAM_ENTRY(PERIOD_TIME),	\
20 	HW_PARAM_ENTRY(PERIOD_SIZE),	\
21 	HW_PARAM_ENTRY(PERIOD_BYTES),	\
22 	HW_PARAM_ENTRY(PERIODS),	\
23 	HW_PARAM_ENTRY(BUFFER_TIME),	\
24 	HW_PARAM_ENTRY(BUFFER_SIZE),	\
25 	HW_PARAM_ENTRY(BUFFER_BYTES),	\
26 	HW_PARAM_ENTRY(TICK_TIME)
27 
28 TRACE_EVENT(hw_mask_param,
29 	TP_PROTO(struct snd_pcm_substream *substream, snd_pcm_hw_param_t type, int index, const struct snd_mask *prev, const struct snd_mask *curr),
30 	TP_ARGS(substream, type, index, prev, curr),
31 	TP_STRUCT__entry(
32 		__field(int, card)
33 		__field(int, device)
34 		__field(int, subdevice)
35 		__field(int, direction)
36 		__field(snd_pcm_hw_param_t, type)
37 		__field(int, index)
38 		__field(int, total)
39 		__array(__u32, prev_bits, 8)
40 		__array(__u32, curr_bits, 8)
41 	),
42 	TP_fast_assign(
43 		__entry->card = substream->pcm->card->number;
44 		__entry->device = substream->pcm->device;
45 		__entry->subdevice = substream->number;
46 		__entry->direction = substream->stream;
47 		__entry->type = type;
48 		__entry->index = index;
49 		__entry->total = substream->runtime->hw_constraints.rules_num;
50 		memcpy(__entry->prev_bits, prev->bits, sizeof(__u32) * 8);
51 		memcpy(__entry->curr_bits, curr->bits, sizeof(__u32) * 8);
52 	),
53 	TP_printk("pcmC%dD%d%s:%d %03d/%03d %s %08x%08x%08x%08x %08x%08x%08x%08x",
54 		  __entry->card,
55 		  __entry->device,
56 		  __entry->direction ? "c" : "p",
57 		  __entry->subdevice,
58 		  __entry->index,
59 		  __entry->total,
60 		  __print_symbolic(__entry->type, hw_param_labels),
61 		  __entry->prev_bits[3], __entry->prev_bits[2],
62 		  __entry->prev_bits[1], __entry->prev_bits[0],
63 		  __entry->curr_bits[3], __entry->curr_bits[2],
64 		  __entry->curr_bits[1], __entry->curr_bits[0]
65 	)
66 );
67 
68 TRACE_EVENT(hw_interval_param,
69 	TP_PROTO(struct snd_pcm_substream *substream, snd_pcm_hw_param_t type, int index, const struct snd_interval *prev, const struct snd_interval *curr),
70 	TP_ARGS(substream, type, index, prev, curr),
71 	TP_STRUCT__entry(
72 		__field(int, card)
73 		__field(int, device)
74 		__field(int, subdevice)
75 		__field(int, direction)
76 		__field(snd_pcm_hw_param_t, type)
77 		__field(int, index)
78 		__field(int, total)
79 		__field(unsigned int, prev_min)
80 		__field(unsigned int, prev_max)
81 		__field(unsigned int, prev_openmin)
82 		__field(unsigned int, prev_openmax)
83 		__field(unsigned int, prev_integer)
84 		__field(unsigned int, prev_empty)
85 		__field(unsigned int, curr_min)
86 		__field(unsigned int, curr_max)
87 		__field(unsigned int, curr_openmin)
88 		__field(unsigned int, curr_openmax)
89 		__field(unsigned int, curr_integer)
90 		__field(unsigned int, curr_empty)
91 	),
92 	TP_fast_assign(
93 		__entry->card = substream->pcm->card->number;
94 		__entry->device = substream->pcm->device;
95 		__entry->subdevice = substream->number;
96 		__entry->direction = substream->stream;
97 		__entry->type = type;
98 		__entry->index = index;
99 		__entry->total = substream->runtime->hw_constraints.rules_num;
100 		__entry->prev_min = prev->min;
101 		__entry->prev_max = prev->max;
102 		__entry->prev_openmin = prev->openmin;
103 		__entry->prev_openmax = prev->openmax;
104 		__entry->prev_integer = prev->integer;
105 		__entry->prev_empty = prev->empty;
106 		__entry->curr_min = curr->min;
107 		__entry->curr_max = curr->max;
108 		__entry->curr_openmin = curr->openmin;
109 		__entry->curr_openmax = curr->openmax;
110 		__entry->curr_integer = curr->integer;
111 		__entry->curr_empty = curr->empty;
112 	),
113 	TP_printk("pcmC%dD%d%s:%d %03d/%03d %s %d %d %s%u %u%s %d %d %s%u %u%s",
114 		  __entry->card,
115 		  __entry->device,
116 		  __entry->direction ? "c" : "p",
117 		  __entry->subdevice,
118 		  __entry->index,
119 		  __entry->total,
120 		  __print_symbolic(__entry->type, hw_param_labels),
121 		  __entry->prev_empty,
122 		  __entry->prev_integer,
123 		  __entry->prev_openmin ? "(" : "[",
124 		  __entry->prev_min,
125 		  __entry->prev_max,
126 		  __entry->prev_openmax ? ")" : "]",
127 		  __entry->curr_empty,
128 		  __entry->curr_integer,
129 		  __entry->curr_openmin ? "(" : "[",
130 		  __entry->curr_min,
131 		  __entry->curr_max,
132 		  __entry->curr_openmax ? ")" : "]"
133 	)
134 );
135 
136 #endif /* _PCM_PARAMS_TRACE_H */
137 
138 /* This part must be outside protection */
139 #undef TRACE_INCLUDE_PATH
140 #define TRACE_INCLUDE_PATH .
141 #undef TRACE_INCLUDE_FILE
142 #define TRACE_INCLUDE_FILE pcm_param_trace
143 #include <trace/define_trace.h>
144