blob: f18da2050772b81906801cfd46f7044aa1f254bb [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Takashi Iwaif5914902014-11-04 12:45:59 +01002#undef TRACE_SYSTEM
3#define TRACE_SYSTEM snd_pcm
4#define TRACE_INCLUDE_FILE pcm_trace
5
6#if !defined(_PCM_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
7#define _PCM_TRACE_H
8
9#include <linux/tracepoint.h>
10
11TRACE_EVENT(hwptr,
12 TP_PROTO(struct snd_pcm_substream *substream, snd_pcm_uframes_t pos, bool irq),
13 TP_ARGS(substream, pos, irq),
14 TP_STRUCT__entry(
15 __field( bool, in_interrupt )
16 __field( unsigned int, card )
17 __field( unsigned int, device )
18 __field( unsigned int, number )
19 __field( unsigned int, stream )
20 __field( snd_pcm_uframes_t, pos )
21 __field( snd_pcm_uframes_t, period_size )
22 __field( snd_pcm_uframes_t, buffer_size )
23 __field( snd_pcm_uframes_t, old_hw_ptr )
24 __field( snd_pcm_uframes_t, hw_ptr_base )
25 ),
26 TP_fast_assign(
27 __entry->in_interrupt = (irq);
28 __entry->card = (substream)->pcm->card->number;
29 __entry->device = (substream)->pcm->device;
30 __entry->number = (substream)->number;
31 __entry->stream = (substream)->stream;
32 __entry->pos = (pos);
33 __entry->period_size = (substream)->runtime->period_size;
34 __entry->buffer_size = (substream)->runtime->buffer_size;
35 __entry->old_hw_ptr = (substream)->runtime->status->hw_ptr;
36 __entry->hw_ptr_base = (substream)->runtime->hw_ptr_base;
37 ),
Takashi Sakamotof5abd532017-06-12 09:41:46 +090038 TP_printk("pcmC%dD%d%s/sub%d: %s: pos=%lu, old=%lu, base=%lu, period=%lu, buf=%lu",
Takashi Iwaif5914902014-11-04 12:45:59 +010039 __entry->card, __entry->device,
Takashi Sakamotof5abd532017-06-12 09:41:46 +090040 __entry->stream == SNDRV_PCM_STREAM_PLAYBACK ? "p" : "c",
Takashi Iwaif5914902014-11-04 12:45:59 +010041 __entry->number,
42 __entry->in_interrupt ? "IRQ" : "POS",
43 (unsigned long)__entry->pos,
44 (unsigned long)__entry->old_hw_ptr,
45 (unsigned long)__entry->hw_ptr_base,
46 (unsigned long)__entry->period_size,
47 (unsigned long)__entry->buffer_size)
48);
49
50TRACE_EVENT(xrun,
51 TP_PROTO(struct snd_pcm_substream *substream),
52 TP_ARGS(substream),
53 TP_STRUCT__entry(
54 __field( unsigned int, card )
55 __field( unsigned int, device )
56 __field( unsigned int, number )
57 __field( unsigned int, stream )
58 __field( snd_pcm_uframes_t, period_size )
59 __field( snd_pcm_uframes_t, buffer_size )
60 __field( snd_pcm_uframes_t, old_hw_ptr )
61 __field( snd_pcm_uframes_t, hw_ptr_base )
62 ),
63 TP_fast_assign(
64 __entry->card = (substream)->pcm->card->number;
65 __entry->device = (substream)->pcm->device;
66 __entry->number = (substream)->number;
67 __entry->stream = (substream)->stream;
68 __entry->period_size = (substream)->runtime->period_size;
69 __entry->buffer_size = (substream)->runtime->buffer_size;
70 __entry->old_hw_ptr = (substream)->runtime->status->hw_ptr;
71 __entry->hw_ptr_base = (substream)->runtime->hw_ptr_base;
72 ),
Takashi Sakamotof5abd532017-06-12 09:41:46 +090073 TP_printk("pcmC%dD%d%s/sub%d: XRUN: old=%lu, base=%lu, period=%lu, buf=%lu",
Takashi Iwaif5914902014-11-04 12:45:59 +010074 __entry->card, __entry->device,
Takashi Sakamotof5abd532017-06-12 09:41:46 +090075 __entry->stream == SNDRV_PCM_STREAM_PLAYBACK ? "p" : "c",
Takashi Iwaif5914902014-11-04 12:45:59 +010076 __entry->number,
77 (unsigned long)__entry->old_hw_ptr,
78 (unsigned long)__entry->hw_ptr_base,
79 (unsigned long)__entry->period_size,
80 (unsigned long)__entry->buffer_size)
81);
82
83TRACE_EVENT(hw_ptr_error,
84 TP_PROTO(struct snd_pcm_substream *substream, const char *why),
85 TP_ARGS(substream, why),
86 TP_STRUCT__entry(
87 __field( unsigned int, card )
88 __field( unsigned int, device )
89 __field( unsigned int, number )
90 __field( unsigned int, stream )
91 __field( const char *, reason )
92 ),
93 TP_fast_assign(
94 __entry->card = (substream)->pcm->card->number;
95 __entry->device = (substream)->pcm->device;
96 __entry->number = (substream)->number;
97 __entry->stream = (substream)->stream;
98 __entry->reason = (why);
99 ),
Takashi Sakamotof5abd532017-06-12 09:41:46 +0900100 TP_printk("pcmC%dD%d%s/sub%d: ERROR: %s",
Takashi Iwaif5914902014-11-04 12:45:59 +0100101 __entry->card, __entry->device,
Takashi Sakamotof5abd532017-06-12 09:41:46 +0900102 __entry->stream == SNDRV_PCM_STREAM_PLAYBACK ? "p" : "c",
Takashi Iwaif5914902014-11-04 12:45:59 +0100103 __entry->number, __entry->reason)
104);
105
Takashi Sakamotofccf5382017-06-12 09:41:45 +0900106TRACE_EVENT(applptr,
107 TP_PROTO(struct snd_pcm_substream *substream, snd_pcm_uframes_t prev, snd_pcm_uframes_t curr),
108 TP_ARGS(substream, prev, curr),
109 TP_STRUCT__entry(
110 __field( unsigned int, card )
111 __field( unsigned int, device )
112 __field( unsigned int, number )
113 __field( unsigned int, stream )
114 __field( snd_pcm_uframes_t, prev )
115 __field( snd_pcm_uframes_t, curr )
116 __field( snd_pcm_uframes_t, avail )
117 __field( snd_pcm_uframes_t, period_size )
118 __field( snd_pcm_uframes_t, buffer_size )
119 ),
120 TP_fast_assign(
121 __entry->card = (substream)->pcm->card->number;
122 __entry->device = (substream)->pcm->device;
123 __entry->number = (substream)->number;
124 __entry->stream = (substream)->stream;
125 __entry->prev = (prev);
126 __entry->curr = (curr);
127 __entry->avail = (substream)->stream ? snd_pcm_capture_avail(substream->runtime) : snd_pcm_playback_avail(substream->runtime);
128 __entry->period_size = (substream)->runtime->period_size;
129 __entry->buffer_size = (substream)->runtime->buffer_size;
130 ),
131 TP_printk("pcmC%dD%d%s/sub%d: prev=%lu, curr=%lu, avail=%lu, period=%lu, buf=%lu",
132 __entry->card,
133 __entry->device,
134 __entry->stream ? "c" : "p",
135 __entry->number,
136 __entry->prev,
137 __entry->curr,
138 __entry->avail,
139 __entry->period_size,
140 __entry->buffer_size
141 )
142);
143
Takashi Iwaif5914902014-11-04 12:45:59 +0100144#endif /* _PCM_TRACE_H */
145
146/* This part must be outside protection */
147#undef TRACE_INCLUDE_PATH
148#define TRACE_INCLUDE_PATH .
149#include <trace/define_trace.h>