xref: /openbmc/linux/sound/core/pcm_trace.h (revision 9b9c2cd4)
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM snd_pcm
3 #define TRACE_INCLUDE_FILE pcm_trace
4 
5 #if !defined(_PCM_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _PCM_TRACE_H
7 
8 #include <linux/tracepoint.h>
9 
10 TRACE_EVENT(hwptr,
11 	TP_PROTO(struct snd_pcm_substream *substream, snd_pcm_uframes_t pos, bool irq),
12 	TP_ARGS(substream, pos, irq),
13 	TP_STRUCT__entry(
14 		__field( bool, in_interrupt )
15 		__field( unsigned int, card )
16 		__field( unsigned int, device )
17 		__field( unsigned int, number )
18 		__field( unsigned int, stream )
19 		__field( snd_pcm_uframes_t, pos )
20 		__field( snd_pcm_uframes_t, period_size )
21 		__field( snd_pcm_uframes_t, buffer_size )
22 		__field( snd_pcm_uframes_t, old_hw_ptr )
23 		__field( snd_pcm_uframes_t, hw_ptr_base )
24 	),
25 	TP_fast_assign(
26 		__entry->in_interrupt = (irq);
27 		__entry->card = (substream)->pcm->card->number;
28 		__entry->device = (substream)->pcm->device;
29 		__entry->number = (substream)->number;
30 		__entry->stream = (substream)->stream;
31 		__entry->pos = (pos);
32 		__entry->period_size = (substream)->runtime->period_size;
33 		__entry->buffer_size = (substream)->runtime->buffer_size;
34 		__entry->old_hw_ptr = (substream)->runtime->status->hw_ptr;
35 		__entry->hw_ptr_base = (substream)->runtime->hw_ptr_base;
36 	),
37 	TP_printk("pcmC%dD%d%c/sub%d: %s: pos=%lu, old=%lu, base=%lu, period=%lu, buf=%lu",
38 		  __entry->card, __entry->device,
39 		  __entry->stream == SNDRV_PCM_STREAM_PLAYBACK ? 'p' : 'c',
40 		  __entry->number,
41 		  __entry->in_interrupt ? "IRQ" : "POS",
42 		  (unsigned long)__entry->pos,
43 		  (unsigned long)__entry->old_hw_ptr,
44 		  (unsigned long)__entry->hw_ptr_base,
45 		  (unsigned long)__entry->period_size,
46 		  (unsigned long)__entry->buffer_size)
47 );
48 
49 TRACE_EVENT(xrun,
50 	TP_PROTO(struct snd_pcm_substream *substream),
51 	TP_ARGS(substream),
52 	TP_STRUCT__entry(
53 		__field( unsigned int, card )
54 		__field( unsigned int, device )
55 		__field( unsigned int, number )
56 		__field( unsigned int, stream )
57 		__field( snd_pcm_uframes_t, period_size )
58 		__field( snd_pcm_uframes_t, buffer_size )
59 		__field( snd_pcm_uframes_t, old_hw_ptr )
60 		__field( snd_pcm_uframes_t, hw_ptr_base )
61 	),
62 	TP_fast_assign(
63 		__entry->card = (substream)->pcm->card->number;
64 		__entry->device = (substream)->pcm->device;
65 		__entry->number = (substream)->number;
66 		__entry->stream = (substream)->stream;
67 		__entry->period_size = (substream)->runtime->period_size;
68 		__entry->buffer_size = (substream)->runtime->buffer_size;
69 		__entry->old_hw_ptr = (substream)->runtime->status->hw_ptr;
70 		__entry->hw_ptr_base = (substream)->runtime->hw_ptr_base;
71 	),
72 	TP_printk("pcmC%dD%d%c/sub%d: XRUN: old=%lu, base=%lu, period=%lu, buf=%lu",
73 		  __entry->card, __entry->device,
74 		  __entry->stream == SNDRV_PCM_STREAM_PLAYBACK ? 'p' : 'c',
75 		  __entry->number,
76 		  (unsigned long)__entry->old_hw_ptr,
77 		  (unsigned long)__entry->hw_ptr_base,
78 		  (unsigned long)__entry->period_size,
79 		  (unsigned long)__entry->buffer_size)
80 );
81 
82 TRACE_EVENT(hw_ptr_error,
83 	TP_PROTO(struct snd_pcm_substream *substream, const char *why),
84 	TP_ARGS(substream, why),
85 	TP_STRUCT__entry(
86 		__field( unsigned int, card )
87 		__field( unsigned int, device )
88 		__field( unsigned int, number )
89 		__field( unsigned int, stream )
90 		__field( const char *, reason )
91 	),
92 	TP_fast_assign(
93 		__entry->card = (substream)->pcm->card->number;
94 		__entry->device = (substream)->pcm->device;
95 		__entry->number = (substream)->number;
96 		__entry->stream = (substream)->stream;
97 		__entry->reason = (why);
98 	),
99 	TP_printk("pcmC%dD%d%c/sub%d: ERROR: %s",
100 		  __entry->card, __entry->device,
101 		  __entry->stream == SNDRV_PCM_STREAM_PLAYBACK ? 'p' : 'c',
102 		  __entry->number, __entry->reason)
103 );
104 
105 #endif /* _PCM_TRACE_H */
106 
107 /* This part must be outside protection */
108 #undef TRACE_INCLUDE_PATH
109 #define TRACE_INCLUDE_PATH .
110 #include <trace/define_trace.h>
111