ALSA: hdac: Add snd_hdac_get_hdac_stream()
authorJeeja KP <jeeja.kp@intel.com>
Sun, 23 Aug 2015 06:22:51 +0000 (11:52 +0530)
committerTakashi Iwai <tiwai@suse.de>
Sun, 23 Aug 2015 07:43:27 +0000 (09:43 +0200)
Add a helper to find the stream using stream tag and direction.
This is useful for drivers to query stream based on stream tag
and direction, fox example while downloading FW thru DSP loader
code

Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/hdaudio.h
sound/hda/hdac_stream.c

index 23a44c39c51c30b14dc346a8938b09e3482baf88..49bc836fcd8483d522c48dc604fc3ba0d1bf153e 100644 (file)
@@ -438,6 +438,8 @@ void snd_hdac_stream_init(struct hdac_bus *bus, struct hdac_stream *azx_dev,
 struct hdac_stream *snd_hdac_stream_assign(struct hdac_bus *bus,
                                           struct snd_pcm_substream *substream);
 void snd_hdac_stream_release(struct hdac_stream *azx_dev);
+struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus,
+                                       int dir, int stream_tag);
 
 int snd_hdac_stream_setup(struct hdac_stream *azx_dev);
 void snd_hdac_stream_cleanup(struct hdac_stream *azx_dev);
index 4c15d0accc9e273ca6e051ffa1483b0f42ce354a..8981159813efb7e361d78d8f26bf032b0565f00b 100644 (file)
@@ -286,6 +286,28 @@ void snd_hdac_stream_release(struct hdac_stream *azx_dev)
 }
 EXPORT_SYMBOL_GPL(snd_hdac_stream_release);
 
+/**
+ * snd_hdac_get_stream - return hdac_stream based on stream_tag and
+ * direction
+ *
+ * @bus: HD-audio core bus
+ * @dir: direction for the stream to be found
+ * @stream_tag: stream tag for stream to be found
+ */
+struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus,
+                                       int dir, int stream_tag)
+{
+       struct hdac_stream *s;
+
+       list_for_each_entry(s, &bus->stream_list, list) {
+               if (s->direction == dir && s->stream_tag == stream_tag)
+                       return s;
+       }
+
+       return NULL;
+}
+EXPORT_SYMBOL_GPL(snd_hdac_get_stream);
+
 /*
  * set up a BDL entry
  */