pcm_trace.h 4.9 KB

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