ALSA: Add snd_pcm_direction_name() helper
authorCezary Rojewski <cezary.rojewski@intel.com>
Wed, 11 May 2022 16:23:50 +0000 (18:23 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 6 Jun 2022 11:33:09 +0000 (12:33 +0100)
Allow for retrieving string naming a direction of a stream without the
need of substream pointer.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220511162403.3987658-2-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/pcm.h

index 6b99310..26523cf 100644 (file)
@@ -1393,6 +1393,20 @@ static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max)
 const char *snd_pcm_format_name(snd_pcm_format_t format);
 
 /**
+ * snd_pcm_direction_name - Get a string naming the direction of a stream
+ * @direction: Stream's direction, one of SNDRV_PCM_STREAM_XXX
+ *
+ * Returns a string naming the direction of the stream.
+ */
+static inline const char *snd_pcm_direction_name(int direction)
+{
+       if (direction == SNDRV_PCM_STREAM_PLAYBACK)
+               return "Playback";
+       else
+               return "Capture";
+}
+
+/**
  * snd_pcm_stream_str - Get a string naming the direction of a stream
  * @substream: the pcm substream instance
  *
@@ -1400,10 +1414,7 @@ const char *snd_pcm_format_name(snd_pcm_format_t format);
  */
 static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream)
 {
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-               return "Playback";
-       else
-               return "Capture";
+       return snd_pcm_direction_name(substream->stream);
 }
 
 /*