aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinod Koul <vinod.koul@intel.com>2015-06-17 01:50:16 -0400
committerTakashi Iwai <tiwai@suse.de>2015-06-17 06:29:26 -0400
commite7a3484dc5b15aa69e44a8b29d9a6e512fa3f922 (patch)
treea1d3532971c04d3e84513cd19ee6df67a25ab31a
parentd39513f85163e202a44283856286fabb6902f2e0 (diff)
ALSA: hda: add hdac_ext stream creation and cleanup routines
HDAC extended core should create streams for an extended bus and also free up those on cleanup. So introduce snd_hdac_ext_stream_init_all and snd_hdac_stream_free_all routines 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>
-rw-r--r--include/sound/hdaudio_ext.h3
-rw-r--r--sound/hda/ext/hdac_ext_stream.c50
2 files changed, 53 insertions, 0 deletions
diff --git a/include/sound/hdaudio_ext.h b/include/sound/hdaudio_ext.h
index 202350a8eddb..877661629322 100644
--- a/include/sound/hdaudio_ext.h
+++ b/include/sound/hdaudio_ext.h
@@ -87,6 +87,9 @@ struct hdac_ext_stream {
87void snd_hdac_ext_stream_init(struct hdac_ext_bus *bus, 87void snd_hdac_ext_stream_init(struct hdac_ext_bus *bus,
88 struct hdac_ext_stream *stream, int idx, 88 struct hdac_ext_stream *stream, int idx,
89 int direction, int tag); 89 int direction, int tag);
90int snd_hdac_ext_stream_init_all(struct hdac_ext_bus *ebus, int start_idx,
91 int num_stream, int dir);
92void snd_hdac_stream_free_all(struct hdac_ext_bus *ebus);
90struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *bus, 93struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *bus,
91 struct snd_pcm_substream *substream, 94 struct snd_pcm_substream *substream,
92 int type); 95 int type);
diff --git a/sound/hda/ext/hdac_ext_stream.c b/sound/hda/ext/hdac_ext_stream.c
index 0677bb65a494..f8ffbdbb450d 100644
--- a/sound/hda/ext/hdac_ext_stream.c
+++ b/sound/hda/ext/hdac_ext_stream.c
@@ -18,6 +18,7 @@
18 */ 18 */
19 19
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/slab.h>
21#include <sound/pcm.h> 22#include <sound/pcm.h>
22#include <sound/hda_register.h> 23#include <sound/hda_register.h>
23#include <sound/hdaudio_ext.h> 24#include <sound/hdaudio_ext.h>
@@ -54,6 +55,55 @@ void snd_hdac_ext_stream_init(struct hdac_ext_bus *ebus,
54EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_init); 55EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_init);
55 56
56/** 57/**
58 * snd_hdac_ext_stream_init_all - create and initialize the stream objects
59 * for an extended hda bus
60 * @ebus: HD-audio ext core bus
61 * @start_idx: start index for streams
62 * @num_stream: number of streams to initialize
63 * @dir: direction of streams
64 */
65int snd_hdac_ext_stream_init_all(struct hdac_ext_bus *ebus, int start_idx,
66 int num_stream, int dir)
67{
68 int stream_tag = 0;
69 int i, tag, idx = start_idx;
70
71 for (i = 0; i < num_stream; i++) {
72 struct hdac_ext_stream *stream =
73 kzalloc(sizeof(*stream), GFP_KERNEL);
74 if (!stream)
75 return -ENOMEM;
76 tag = ++stream_tag;
77 snd_hdac_ext_stream_init(ebus, stream, idx, dir, tag);
78 idx++;
79 }
80
81 return 0;
82
83}
84EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_init_all);
85
86/**
87 * snd_hdac_stream_free_all - free hdac extended stream objects
88 *
89 * @ebus: HD-audio ext core bus
90 */
91void snd_hdac_stream_free_all(struct hdac_ext_bus *ebus)
92{
93 struct hdac_stream *s;
94 struct hdac_ext_stream *stream;
95 struct hdac_bus *bus = ebus_to_hbus(ebus);
96
97 while (!list_empty(&bus->stream_list)) {
98 s = list_first_entry(&bus->stream_list, struct hdac_stream, list);
99 stream = stream_to_hdac_ext_stream(s);
100 list_del(&s->list);
101 kfree(stream);
102 }
103}
104EXPORT_SYMBOL_GPL(snd_hdac_stream_free_all);
105
106/**
57 * snd_hdac_ext_stream_decouple - decouple the hdac stream 107 * snd_hdac_ext_stream_decouple - decouple the hdac stream
58 * @ebus: HD-audio ext core bus 108 * @ebus: HD-audio ext core bus
59 * @stream: HD-audio ext core stream object to initialize 109 * @stream: HD-audio ext core stream object to initialize