pcm_trace.h 5.0 KB

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