xref: /openbmc/linux/sound/core/pcm_trace.h (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2f5914908STakashi Iwai #undef TRACE_SYSTEM
3f5914908STakashi Iwai #define TRACE_SYSTEM snd_pcm
4f5914908STakashi Iwai #define TRACE_INCLUDE_FILE pcm_trace
5f5914908STakashi Iwai 
6f5914908STakashi Iwai #if !defined(_PCM_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
7f5914908STakashi Iwai #define _PCM_TRACE_H
8f5914908STakashi Iwai 
9f5914908STakashi Iwai #include <linux/tracepoint.h>
10f5914908STakashi Iwai 
11f5914908STakashi Iwai TRACE_EVENT(hwptr,
12f5914908STakashi Iwai 	TP_PROTO(struct snd_pcm_substream *substream, snd_pcm_uframes_t pos, bool irq),
13f5914908STakashi Iwai 	TP_ARGS(substream, pos, irq),
14f5914908STakashi Iwai 	TP_STRUCT__entry(
15f5914908STakashi Iwai 		__field( bool, in_interrupt )
16f5914908STakashi Iwai 		__field( unsigned int, card )
17f5914908STakashi Iwai 		__field( unsigned int, device )
18f5914908STakashi Iwai 		__field( unsigned int, number )
19f5914908STakashi Iwai 		__field( unsigned int, stream )
20f5914908STakashi Iwai 		__field( snd_pcm_uframes_t, pos )
21f5914908STakashi Iwai 		__field( snd_pcm_uframes_t, period_size )
22f5914908STakashi Iwai 		__field( snd_pcm_uframes_t, buffer_size )
23f5914908STakashi Iwai 		__field( snd_pcm_uframes_t, old_hw_ptr )
24f5914908STakashi Iwai 		__field( snd_pcm_uframes_t, hw_ptr_base )
25f5914908STakashi Iwai 	),
26f5914908STakashi Iwai 	TP_fast_assign(
27f5914908STakashi Iwai 		__entry->in_interrupt = (irq);
28f5914908STakashi Iwai 		__entry->card = (substream)->pcm->card->number;
29f5914908STakashi Iwai 		__entry->device = (substream)->pcm->device;
30f5914908STakashi Iwai 		__entry->number = (substream)->number;
31f5914908STakashi Iwai 		__entry->stream = (substream)->stream;
32f5914908STakashi Iwai 		__entry->pos = (pos);
33f5914908STakashi Iwai 		__entry->period_size = (substream)->runtime->period_size;
34f5914908STakashi Iwai 		__entry->buffer_size = (substream)->runtime->buffer_size;
35f5914908STakashi Iwai 		__entry->old_hw_ptr = (substream)->runtime->status->hw_ptr;
36f5914908STakashi Iwai 		__entry->hw_ptr_base = (substream)->runtime->hw_ptr_base;
37f5914908STakashi Iwai 	),
38f5abd532STakashi Sakamoto 	TP_printk("pcmC%dD%d%s/sub%d: %s: pos=%lu, old=%lu, base=%lu, period=%lu, buf=%lu",
39f5914908STakashi Iwai 		  __entry->card, __entry->device,
40f5abd532STakashi Sakamoto 		  __entry->stream == SNDRV_PCM_STREAM_PLAYBACK ? "p" : "c",
41f5914908STakashi Iwai 		  __entry->number,
42f5914908STakashi Iwai 		  __entry->in_interrupt ? "IRQ" : "POS",
43f5914908STakashi Iwai 		  (unsigned long)__entry->pos,
44f5914908STakashi Iwai 		  (unsigned long)__entry->old_hw_ptr,
45f5914908STakashi Iwai 		  (unsigned long)__entry->hw_ptr_base,
46f5914908STakashi Iwai 		  (unsigned long)__entry->period_size,
47f5914908STakashi Iwai 		  (unsigned long)__entry->buffer_size)
48f5914908STakashi Iwai );
49f5914908STakashi Iwai 
50f5914908STakashi Iwai TRACE_EVENT(xrun,
51f5914908STakashi Iwai 	TP_PROTO(struct snd_pcm_substream *substream),
52f5914908STakashi Iwai 	TP_ARGS(substream),
53f5914908STakashi Iwai 	TP_STRUCT__entry(
54f5914908STakashi Iwai 		__field( unsigned int, card )
55f5914908STakashi Iwai 		__field( unsigned int, device )
56f5914908STakashi Iwai 		__field( unsigned int, number )
57f5914908STakashi Iwai 		__field( unsigned int, stream )
58f5914908STakashi Iwai 		__field( snd_pcm_uframes_t, period_size )
59f5914908STakashi Iwai 		__field( snd_pcm_uframes_t, buffer_size )
60f5914908STakashi Iwai 		__field( snd_pcm_uframes_t, old_hw_ptr )
61f5914908STakashi Iwai 		__field( snd_pcm_uframes_t, hw_ptr_base )
62f5914908STakashi Iwai 	),
63f5914908STakashi Iwai 	TP_fast_assign(
64f5914908STakashi Iwai 		__entry->card = (substream)->pcm->card->number;
65f5914908STakashi Iwai 		__entry->device = (substream)->pcm->device;
66f5914908STakashi Iwai 		__entry->number = (substream)->number;
67f5914908STakashi Iwai 		__entry->stream = (substream)->stream;
68f5914908STakashi Iwai 		__entry->period_size = (substream)->runtime->period_size;
69f5914908STakashi Iwai 		__entry->buffer_size = (substream)->runtime->buffer_size;
70f5914908STakashi Iwai 		__entry->old_hw_ptr = (substream)->runtime->status->hw_ptr;
71f5914908STakashi Iwai 		__entry->hw_ptr_base = (substream)->runtime->hw_ptr_base;
72f5914908STakashi Iwai 	),
73f5abd532STakashi Sakamoto 	TP_printk("pcmC%dD%d%s/sub%d: XRUN: old=%lu, base=%lu, period=%lu, buf=%lu",
74f5914908STakashi Iwai 		  __entry->card, __entry->device,
75f5abd532STakashi Sakamoto 		  __entry->stream == SNDRV_PCM_STREAM_PLAYBACK ? "p" : "c",
76f5914908STakashi Iwai 		  __entry->number,
77f5914908STakashi Iwai 		  (unsigned long)__entry->old_hw_ptr,
78f5914908STakashi Iwai 		  (unsigned long)__entry->hw_ptr_base,
79f5914908STakashi Iwai 		  (unsigned long)__entry->period_size,
80f5914908STakashi Iwai 		  (unsigned long)__entry->buffer_size)
81f5914908STakashi Iwai );
82f5914908STakashi Iwai 
83f5914908STakashi Iwai TRACE_EVENT(hw_ptr_error,
84f5914908STakashi Iwai 	TP_PROTO(struct snd_pcm_substream *substream, const char *why),
85f5914908STakashi Iwai 	TP_ARGS(substream, why),
86f5914908STakashi Iwai 	TP_STRUCT__entry(
87f5914908STakashi Iwai 		__field( unsigned int, card )
88f5914908STakashi Iwai 		__field( unsigned int, device )
89f5914908STakashi Iwai 		__field( unsigned int, number )
90f5914908STakashi Iwai 		__field( unsigned int, stream )
91*e4baf845SJohn Keeping 		__string( reason, why )
92f5914908STakashi Iwai 	),
93f5914908STakashi Iwai 	TP_fast_assign(
94f5914908STakashi Iwai 		__entry->card = (substream)->pcm->card->number;
95f5914908STakashi Iwai 		__entry->device = (substream)->pcm->device;
96f5914908STakashi Iwai 		__entry->number = (substream)->number;
97f5914908STakashi Iwai 		__entry->stream = (substream)->stream;
98*e4baf845SJohn Keeping 		__assign_str(reason, why);
99f5914908STakashi Iwai 	),
100f5abd532STakashi Sakamoto 	TP_printk("pcmC%dD%d%s/sub%d: ERROR: %s",
101f5914908STakashi Iwai 		  __entry->card, __entry->device,
102f5abd532STakashi Sakamoto 		  __entry->stream == SNDRV_PCM_STREAM_PLAYBACK ? "p" : "c",
103*e4baf845SJohn Keeping 		  __entry->number, __get_str(reason))
104f5914908STakashi Iwai );
105f5914908STakashi Iwai 
106fccf5388STakashi Sakamoto TRACE_EVENT(applptr,
107fccf5388STakashi Sakamoto 	TP_PROTO(struct snd_pcm_substream *substream, snd_pcm_uframes_t prev, snd_pcm_uframes_t curr),
108fccf5388STakashi Sakamoto 	TP_ARGS(substream, prev, curr),
109fccf5388STakashi Sakamoto 	TP_STRUCT__entry(
110fccf5388STakashi Sakamoto 		__field( unsigned int, card )
111fccf5388STakashi Sakamoto 		__field( unsigned int, device )
112fccf5388STakashi Sakamoto 		__field( unsigned int, number )
113fccf5388STakashi Sakamoto 		__field( unsigned int, stream )
114fccf5388STakashi Sakamoto 		__field( snd_pcm_uframes_t, prev )
115fccf5388STakashi Sakamoto 		__field( snd_pcm_uframes_t, curr )
116fccf5388STakashi Sakamoto 		__field( snd_pcm_uframes_t, avail )
117fccf5388STakashi Sakamoto 		__field( snd_pcm_uframes_t, period_size )
118fccf5388STakashi Sakamoto 		__field( snd_pcm_uframes_t, buffer_size )
119fccf5388STakashi Sakamoto 	),
120fccf5388STakashi Sakamoto 	TP_fast_assign(
121fccf5388STakashi Sakamoto 		__entry->card = (substream)->pcm->card->number;
122fccf5388STakashi Sakamoto 		__entry->device = (substream)->pcm->device;
123fccf5388STakashi Sakamoto 		__entry->number = (substream)->number;
124fccf5388STakashi Sakamoto 		__entry->stream = (substream)->stream;
125fccf5388STakashi Sakamoto 		__entry->prev = (prev);
126fccf5388STakashi Sakamoto 		__entry->curr = (curr);
127fccf5388STakashi Sakamoto 		__entry->avail = (substream)->stream ? snd_pcm_capture_avail(substream->runtime) : snd_pcm_playback_avail(substream->runtime);
128fccf5388STakashi Sakamoto 		__entry->period_size = (substream)->runtime->period_size;
129fccf5388STakashi Sakamoto 		__entry->buffer_size = (substream)->runtime->buffer_size;
130fccf5388STakashi Sakamoto 	),
131fccf5388STakashi Sakamoto 	TP_printk("pcmC%dD%d%s/sub%d: prev=%lu, curr=%lu, avail=%lu, period=%lu, buf=%lu",
132fccf5388STakashi Sakamoto 		__entry->card,
133fccf5388STakashi Sakamoto 		__entry->device,
134fccf5388STakashi Sakamoto 		__entry->stream ? "c" : "p",
135fccf5388STakashi Sakamoto 		__entry->number,
136fccf5388STakashi Sakamoto 		__entry->prev,
137fccf5388STakashi Sakamoto 		__entry->curr,
138fccf5388STakashi Sakamoto 		__entry->avail,
139fccf5388STakashi Sakamoto 		__entry->period_size,
140fccf5388STakashi Sakamoto 		__entry->buffer_size
141fccf5388STakashi Sakamoto 	)
142fccf5388STakashi Sakamoto );
143fccf5388STakashi Sakamoto 
144f5914908STakashi Iwai #endif /* _PCM_TRACE_H */
145f5914908STakashi Iwai 
146f5914908STakashi Iwai /* This part must be outside protection */
147f5914908STakashi Iwai #undef TRACE_INCLUDE_PATH
148f5914908STakashi Iwai #define TRACE_INCLUDE_PATH .
149f5914908STakashi Iwai #include <trace/define_trace.h>
150