1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #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 11 TRACE_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 ), 38 TP_printk("pcmC%dD%d%s/sub%d: %s: pos=%lu, old=%lu, base=%lu, period=%lu, buf=%lu", 39 __entry->card, __entry->device, 40 __entry->stream == SNDRV_PCM_STREAM_PLAYBACK ? "p" : "c", 41 __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 50 TRACE_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 ), 73 TP_printk("pcmC%dD%d%s/sub%d: XRUN: old=%lu, base=%lu, period=%lu, buf=%lu", 74 __entry->card, __entry->device, 75 __entry->stream == SNDRV_PCM_STREAM_PLAYBACK ? "p" : "c", 76 __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 83 TRACE_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 ), 100 TP_printk("pcmC%dD%d%s/sub%d: ERROR: %s", 101 __entry->card, __entry->device, 102 __entry->stream == SNDRV_PCM_STREAM_PLAYBACK ? "p" : "c", 103 __entry->number, __entry->reason) 104 ); 105 106 TRACE_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 144 #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> 150