summaryrefslogtreecommitdiffstats
path: root/sound/hda
diff options
context:
space:
mode:
authorRakesh Ughreja <rakesh.a.ughreja@intel.com>2018-06-01 23:53:50 -0400
committerTakashi Iwai <tiwai@suse.de>2018-06-28 01:33:29 -0400
commit76f56fae1cf9040325a58d1375291baf71dfaf03 (patch)
treeecc691b24f517dbaf6729b3a0e4d80f3f16a669b /sound/hda
parent3787a39852b0d6a9e67336f8fb5815c13ab78bb6 (diff)
ALSA: hdac: Remove usage of struct hdac_ext_bus and use hdac_bus instead
This patch removes the hdac_ext_bus structure. The legacy and enhanced HDaudio capabilities can be handled in a backward-compatible way without separate definitions. Follow-up patches in this series handle the driver definition. Signed-off-by: Rakesh Ughreja <rakesh.a.ughreja@intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/hda')
-rw-r--r--sound/hda/ext/hdac_ext_bus.c27
-rw-r--r--sound/hda/ext/hdac_ext_controller.c55
-rw-r--r--sound/hda/ext/hdac_ext_stream.c104
3 files changed, 84 insertions, 102 deletions
diff --git a/sound/hda/ext/hdac_ext_bus.c b/sound/hda/ext/hdac_ext_bus.c
index 0e4823fdd411..77547ede9ae8 100644
--- a/sound/hda/ext/hdac_ext_bus.c
+++ b/sound/hda/ext/hdac_ext_bus.c
@@ -87,7 +87,7 @@ static const struct hdac_io_ops hdac_ext_default_io = {
87 * 87 *
88 * Returns 0 if successful, or a negative error code. 88 * Returns 0 if successful, or a negative error code.
89 */ 89 */
90int snd_hdac_ext_bus_init(struct hdac_ext_bus *ebus, struct device *dev, 90int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev,
91 const struct hdac_bus_ops *ops, 91 const struct hdac_bus_ops *ops,
92 const struct hdac_io_ops *io_ops) 92 const struct hdac_io_ops *io_ops)
93{ 93{
@@ -98,15 +98,15 @@ int snd_hdac_ext_bus_init(struct hdac_ext_bus *ebus, struct device *dev,
98 if (io_ops == NULL) 98 if (io_ops == NULL)
99 io_ops = &hdac_ext_default_io; 99 io_ops = &hdac_ext_default_io;
100 100
101 ret = snd_hdac_bus_init(&ebus->bus, dev, ops, io_ops); 101 ret = snd_hdac_bus_init(bus, dev, ops, io_ops);
102 if (ret < 0) 102 if (ret < 0)
103 return ret; 103 return ret;
104 104
105 INIT_LIST_HEAD(&ebus->hlink_list); 105 INIT_LIST_HEAD(&bus->hlink_list);
106 ebus->idx = idx++; 106 bus->idx = idx++;
107 107
108 mutex_init(&ebus->lock); 108 mutex_init(&bus->lock);
109 ebus->cmd_dma_state = true; 109 bus->cmd_dma_state = true;
110 110
111 return 0; 111 return 0;
112} 112}
@@ -116,10 +116,10 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_init);
116 * snd_hdac_ext_bus_exit - clean up a HD-audio extended bus 116 * snd_hdac_ext_bus_exit - clean up a HD-audio extended bus
117 * @ebus: the pointer to extended bus object 117 * @ebus: the pointer to extended bus object
118 */ 118 */
119void snd_hdac_ext_bus_exit(struct hdac_ext_bus *ebus) 119void snd_hdac_ext_bus_exit(struct hdac_bus *bus)
120{ 120{
121 snd_hdac_bus_exit(&ebus->bus); 121 snd_hdac_bus_exit(bus);
122 WARN_ON(!list_empty(&ebus->hlink_list)); 122 WARN_ON(!list_empty(&bus->hlink_list));
123} 123}
124EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_exit); 124EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_exit);
125 125
@@ -135,10 +135,9 @@ static void default_release(struct device *dev)
135 * 135 *
136 * Returns zero for success or a negative error code. 136 * Returns zero for success or a negative error code.
137 */ 137 */
138int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *ebus, int addr) 138int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr)
139{ 139{
140 struct hdac_device *hdev = NULL; 140 struct hdac_device *hdev = NULL;
141 struct hdac_bus *bus = ebus_to_hbus(ebus);
142 char name[15]; 141 char name[15];
143 int ret; 142 int ret;
144 143
@@ -148,7 +147,7 @@ int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *ebus, int addr)
148 147
149 hdev->bus = bus; 148 hdev->bus = bus;
150 149
151 snprintf(name, sizeof(name), "ehdaudio%dD%d", ebus->idx, addr); 150 snprintf(name, sizeof(name), "ehdaudio%dD%d", bus->idx, addr);
152 151
153 ret = snd_hdac_device_init(hdev, bus, name, addr); 152 ret = snd_hdac_device_init(hdev, bus, name, addr);
154 if (ret < 0) { 153 if (ret < 0) {
@@ -185,14 +184,14 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit);
185 * 184 *
186 * @ebus: HD-audio extended bus 185 * @ebus: HD-audio extended bus
187 */ 186 */
188void snd_hdac_ext_bus_device_remove(struct hdac_ext_bus *ebus) 187void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus)
189{ 188{
190 struct hdac_device *codec, *__codec; 189 struct hdac_device *codec, *__codec;
191 /* 190 /*
192 * we need to remove all the codec devices objects created in the 191 * we need to remove all the codec devices objects created in the
193 * snd_hdac_ext_bus_device_init 192 * snd_hdac_ext_bus_device_init
194 */ 193 */
195 list_for_each_entry_safe(codec, __codec, &ebus->bus.codec_list, list) { 194 list_for_each_entry_safe(codec, __codec, &bus->codec_list, list) {
196 snd_hdac_device_unregister(codec); 195 snd_hdac_device_unregister(codec);
197 put_device(&codec->dev); 196 put_device(&codec->dev);
198 } 197 }
diff --git a/sound/hda/ext/hdac_ext_controller.c b/sound/hda/ext/hdac_ext_controller.c
index 84f3b8168716..72774119dd11 100644
--- a/sound/hda/ext/hdac_ext_controller.c
+++ b/sound/hda/ext/hdac_ext_controller.c
@@ -39,9 +39,8 @@
39 * @ebus: HD-audio extended core bus 39 * @ebus: HD-audio extended core bus
40 * @enable: flag to turn on/off the capability 40 * @enable: flag to turn on/off the capability
41 */ 41 */
42void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *ebus, bool enable) 42void snd_hdac_ext_bus_ppcap_enable(struct hdac_bus *bus, bool enable)
43{ 43{
44 struct hdac_bus *bus = &ebus->bus;
45 44
46 if (!bus->ppcap) { 45 if (!bus->ppcap) {
47 dev_err(bus->dev, "Address of PP capability is NULL"); 46 dev_err(bus->dev, "Address of PP capability is NULL");
@@ -60,9 +59,8 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_ppcap_enable);
60 * @ebus: HD-audio extended core bus 59 * @ebus: HD-audio extended core bus
61 * @enable: flag to enable/disable interrupt 60 * @enable: flag to enable/disable interrupt
62 */ 61 */
63void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *ebus, bool enable) 62void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_bus *bus, bool enable)
64{ 63{
65 struct hdac_bus *bus = &ebus->bus;
66 64
67 if (!bus->ppcap) { 65 if (!bus->ppcap) {
68 dev_err(bus->dev, "Address of PP capability is NULL\n"); 66 dev_err(bus->dev, "Address of PP capability is NULL\n");
@@ -89,12 +87,11 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_ppcap_int_enable);
89 * in hlink_list of extended hdac bus 87 * in hlink_list of extended hdac bus
90 * Note: this will be freed on bus exit by driver 88 * Note: this will be freed on bus exit by driver
91 */ 89 */
92int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *ebus) 90int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus)
93{ 91{
94 int idx; 92 int idx;
95 u32 link_count; 93 u32 link_count;
96 struct hdac_ext_link *hlink; 94 struct hdac_ext_link *hlink;
97 struct hdac_bus *bus = &ebus->bus;
98 95
99 link_count = readl(bus->mlcap + AZX_REG_ML_MLCD) + 1; 96 link_count = readl(bus->mlcap + AZX_REG_ML_MLCD) + 1;
100 97
@@ -114,7 +111,7 @@ int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *ebus)
114 /* since link in On, update the ref */ 111 /* since link in On, update the ref */
115 hlink->ref_count = 1; 112 hlink->ref_count = 1;
116 113
117 list_add_tail(&hlink->list, &ebus->hlink_list); 114 list_add_tail(&hlink->list, &bus->hlink_list);
118 } 115 }
119 116
120 return 0; 117 return 0;
@@ -127,12 +124,12 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_get_ml_capabilities);
127 * @ebus: HD-audio ext core bus 124 * @ebus: HD-audio ext core bus
128 */ 125 */
129 126
130void snd_hdac_link_free_all(struct hdac_ext_bus *ebus) 127void snd_hdac_link_free_all(struct hdac_bus *bus)
131{ 128{
132 struct hdac_ext_link *l; 129 struct hdac_ext_link *l;
133 130
134 while (!list_empty(&ebus->hlink_list)) { 131 while (!list_empty(&bus->hlink_list)) {
135 l = list_first_entry(&ebus->hlink_list, struct hdac_ext_link, list); 132 l = list_first_entry(&bus->hlink_list, struct hdac_ext_link, list);
136 list_del(&l->list); 133 list_del(&l->list);
137 kfree(l); 134 kfree(l);
138 } 135 }
@@ -144,7 +141,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_link_free_all);
144 * @ebus: HD-audio extended core bus 141 * @ebus: HD-audio extended core bus
145 * @codec_name: codec name 142 * @codec_name: codec name
146 */ 143 */
147struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *ebus, 144struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus,
148 const char *codec_name) 145 const char *codec_name)
149{ 146{
150 int i; 147 int i;
@@ -153,10 +150,10 @@ struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *ebus,
153 150
154 if (sscanf(codec_name, "ehdaudio%dD%d", &bus_idx, &addr) != 2) 151 if (sscanf(codec_name, "ehdaudio%dD%d", &bus_idx, &addr) != 2)
155 return NULL; 152 return NULL;
156 if (ebus->idx != bus_idx) 153 if (bus->idx != bus_idx)
157 return NULL; 154 return NULL;
158 155
159 list_for_each_entry(hlink, &ebus->hlink_list, list) { 156 list_for_each_entry(hlink, &bus->hlink_list, list) {
160 for (i = 0; i < HDA_MAX_CODECS; i++) { 157 for (i = 0; i < HDA_MAX_CODECS; i++) {
161 if (hlink->lsdiid & (0x1 << addr)) 158 if (hlink->lsdiid & (0x1 << addr))
162 return hlink; 159 return hlink;
@@ -219,12 +216,12 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_down);
219 * snd_hdac_ext_bus_link_power_up_all -power up all hda link 216 * snd_hdac_ext_bus_link_power_up_all -power up all hda link
220 * @ebus: HD-audio extended bus 217 * @ebus: HD-audio extended bus
221 */ 218 */
222int snd_hdac_ext_bus_link_power_up_all(struct hdac_ext_bus *ebus) 219int snd_hdac_ext_bus_link_power_up_all(struct hdac_bus *bus)
223{ 220{
224 struct hdac_ext_link *hlink = NULL; 221 struct hdac_ext_link *hlink = NULL;
225 int ret; 222 int ret;
226 223
227 list_for_each_entry(hlink, &ebus->hlink_list, list) { 224 list_for_each_entry(hlink, &bus->hlink_list, list) {
228 snd_hdac_updatel(hlink->ml_addr, 225 snd_hdac_updatel(hlink->ml_addr,
229 AZX_REG_ML_LCTL, 0, AZX_MLCTL_SPA); 226 AZX_REG_ML_LCTL, 0, AZX_MLCTL_SPA);
230 ret = check_hdac_link_power_active(hlink, true); 227 ret = check_hdac_link_power_active(hlink, true);
@@ -240,12 +237,12 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_up_all);
240 * snd_hdac_ext_bus_link_power_down_all -power down all hda link 237 * snd_hdac_ext_bus_link_power_down_all -power down all hda link
241 * @ebus: HD-audio extended bus 238 * @ebus: HD-audio extended bus
242 */ 239 */
243int snd_hdac_ext_bus_link_power_down_all(struct hdac_ext_bus *ebus) 240int snd_hdac_ext_bus_link_power_down_all(struct hdac_bus *bus)
244{ 241{
245 struct hdac_ext_link *hlink = NULL; 242 struct hdac_ext_link *hlink = NULL;
246 int ret; 243 int ret;
247 244
248 list_for_each_entry(hlink, &ebus->hlink_list, list) { 245 list_for_each_entry(hlink, &bus->hlink_list, list) {
249 snd_hdac_updatel(hlink->ml_addr, AZX_REG_ML_LCTL, AZX_MLCTL_SPA, 0); 246 snd_hdac_updatel(hlink->ml_addr, AZX_REG_ML_LCTL, AZX_MLCTL_SPA, 0);
250 ret = check_hdac_link_power_active(hlink, false); 247 ret = check_hdac_link_power_active(hlink, false);
251 if (ret < 0) 248 if (ret < 0)
@@ -256,39 +253,39 @@ int snd_hdac_ext_bus_link_power_down_all(struct hdac_ext_bus *ebus)
256} 253}
257EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_down_all); 254EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_down_all);
258 255
259int snd_hdac_ext_bus_link_get(struct hdac_ext_bus *ebus, 256int snd_hdac_ext_bus_link_get(struct hdac_bus *bus,
260 struct hdac_ext_link *link) 257 struct hdac_ext_link *link)
261{ 258{
262 int ret = 0; 259 int ret = 0;
263 260
264 mutex_lock(&ebus->lock); 261 mutex_lock(&bus->lock);
265 262
266 /* 263 /*
267 * if we move from 0 to 1, count will be 1 so power up this link 264 * if we move from 0 to 1, count will be 1 so power up this link
268 * as well, also check the dma status and trigger that 265 * as well, also check the dma status and trigger that
269 */ 266 */
270 if (++link->ref_count == 1) { 267 if (++link->ref_count == 1) {
271 if (!ebus->cmd_dma_state) { 268 if (!bus->cmd_dma_state) {
272 snd_hdac_bus_init_cmd_io(&ebus->bus); 269 snd_hdac_bus_init_cmd_io(bus);
273 ebus->cmd_dma_state = true; 270 bus->cmd_dma_state = true;
274 } 271 }
275 272
276 ret = snd_hdac_ext_bus_link_power_up(link); 273 ret = snd_hdac_ext_bus_link_power_up(link);
277 } 274 }
278 275
279 mutex_unlock(&ebus->lock); 276 mutex_unlock(&bus->lock);
280 return ret; 277 return ret;
281} 278}
282EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_get); 279EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_get);
283 280
284int snd_hdac_ext_bus_link_put(struct hdac_ext_bus *ebus, 281int snd_hdac_ext_bus_link_put(struct hdac_bus *bus,
285 struct hdac_ext_link *link) 282 struct hdac_ext_link *link)
286{ 283{
287 int ret = 0; 284 int ret = 0;
288 struct hdac_ext_link *hlink; 285 struct hdac_ext_link *hlink;
289 bool link_up = false; 286 bool link_up = false;
290 287
291 mutex_lock(&ebus->lock); 288 mutex_lock(&bus->lock);
292 289
293 /* 290 /*
294 * if we move from 1 to 0, count will be 0 291 * if we move from 1 to 0, count will be 0
@@ -301,7 +298,7 @@ int snd_hdac_ext_bus_link_put(struct hdac_ext_bus *ebus,
301 * now check if all links are off, if so turn off 298 * now check if all links are off, if so turn off
302 * cmd dma as well 299 * cmd dma as well
303 */ 300 */
304 list_for_each_entry(hlink, &ebus->hlink_list, list) { 301 list_for_each_entry(hlink, &bus->hlink_list, list) {
305 if (hlink->ref_count) { 302 if (hlink->ref_count) {
306 link_up = true; 303 link_up = true;
307 break; 304 break;
@@ -309,12 +306,12 @@ int snd_hdac_ext_bus_link_put(struct hdac_ext_bus *ebus,
309 } 306 }
310 307
311 if (!link_up) { 308 if (!link_up) {
312 snd_hdac_bus_stop_cmd_io(&ebus->bus); 309 snd_hdac_bus_stop_cmd_io(bus);
313 ebus->cmd_dma_state = false; 310 bus->cmd_dma_state = false;
314 } 311 }
315 } 312 }
316 313
317 mutex_unlock(&ebus->lock); 314 mutex_unlock(&bus->lock);
318 return ret; 315 return ret;
319} 316}
320EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_put); 317EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_put);
diff --git a/sound/hda/ext/hdac_ext_stream.c b/sound/hda/ext/hdac_ext_stream.c
index c96d7a7a36af..1bd27576db98 100644
--- a/sound/hda/ext/hdac_ext_stream.c
+++ b/sound/hda/ext/hdac_ext_stream.c
@@ -25,7 +25,7 @@
25 25
26/** 26/**
27 * snd_hdac_ext_stream_init - initialize each stream (aka device) 27 * snd_hdac_ext_stream_init - initialize each stream (aka device)
28 * @ebus: HD-audio ext core bus 28 * @bus: HD-audio core bus
29 * @stream: HD-audio ext core stream object to initialize 29 * @stream: HD-audio ext core stream object to initialize
30 * @idx: stream index number 30 * @idx: stream index number
31 * @direction: stream direction (SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE) 31 * @direction: stream direction (SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE)
@@ -34,18 +34,16 @@
34 * initialize the stream, if ppcap is enabled then init those and then 34 * initialize the stream, if ppcap is enabled then init those and then
35 * invoke hdac stream initialization routine 35 * invoke hdac stream initialization routine
36 */ 36 */
37void snd_hdac_ext_stream_init(struct hdac_ext_bus *ebus, 37void snd_hdac_ext_stream_init(struct hdac_bus *bus,
38 struct hdac_ext_stream *stream, 38 struct hdac_ext_stream *stream,
39 int idx, int direction, int tag) 39 int idx, int direction, int tag)
40{ 40{
41 struct hdac_bus *bus = &ebus->bus;
42
43 if (bus->ppcap) { 41 if (bus->ppcap) {
44 stream->pphc_addr = bus->ppcap + AZX_PPHC_BASE + 42 stream->pphc_addr = bus->ppcap + AZX_PPHC_BASE +
45 AZX_PPHC_INTERVAL * idx; 43 AZX_PPHC_INTERVAL * idx;
46 44
47 stream->pplc_addr = bus->ppcap + AZX_PPLC_BASE + 45 stream->pplc_addr = bus->ppcap + AZX_PPLC_BASE +
48 AZX_PPLC_MULTI * ebus->num_streams + 46 AZX_PPLC_MULTI * bus->num_streams +
49 AZX_PPLC_INTERVAL * idx; 47 AZX_PPLC_INTERVAL * idx;
50 } 48 }
51 49
@@ -71,12 +69,12 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_init);
71/** 69/**
72 * snd_hdac_ext_stream_init_all - create and initialize the stream objects 70 * snd_hdac_ext_stream_init_all - create and initialize the stream objects
73 * for an extended hda bus 71 * for an extended hda bus
74 * @ebus: HD-audio ext core bus 72 * @bus: HD-audio core bus
75 * @start_idx: start index for streams 73 * @start_idx: start index for streams
76 * @num_stream: number of streams to initialize 74 * @num_stream: number of streams to initialize
77 * @dir: direction of streams 75 * @dir: direction of streams
78 */ 76 */
79int snd_hdac_ext_stream_init_all(struct hdac_ext_bus *ebus, int start_idx, 77int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
80 int num_stream, int dir) 78 int num_stream, int dir)
81{ 79{
82 int stream_tag = 0; 80 int stream_tag = 0;
@@ -88,7 +86,7 @@ int snd_hdac_ext_stream_init_all(struct hdac_ext_bus *ebus, int start_idx,
88 if (!stream) 86 if (!stream)
89 return -ENOMEM; 87 return -ENOMEM;
90 tag = ++stream_tag; 88 tag = ++stream_tag;
91 snd_hdac_ext_stream_init(ebus, stream, idx, dir, tag); 89 snd_hdac_ext_stream_init(bus, stream, idx, dir, tag);
92 idx++; 90 idx++;
93 } 91 }
94 92
@@ -100,17 +98,16 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_init_all);
100/** 98/**
101 * snd_hdac_stream_free_all - free hdac extended stream objects 99 * snd_hdac_stream_free_all - free hdac extended stream objects
102 * 100 *
103 * @ebus: HD-audio ext core bus 101 * @bus: HD-audio core bus
104 */ 102 */
105void snd_hdac_stream_free_all(struct hdac_ext_bus *ebus) 103void snd_hdac_stream_free_all(struct hdac_bus *bus)
106{ 104{
107 struct hdac_stream *s, *_s; 105 struct hdac_stream *s, *_s;
108 struct hdac_ext_stream *stream; 106 struct hdac_ext_stream *stream;
109 struct hdac_bus *bus = ebus_to_hbus(ebus);
110 107
111 list_for_each_entry_safe(s, _s, &bus->stream_list, list) { 108 list_for_each_entry_safe(s, _s, &bus->stream_list, list) {
112 stream = stream_to_hdac_ext_stream(s); 109 stream = stream_to_hdac_ext_stream(s);
113 snd_hdac_ext_stream_decouple(ebus, stream, false); 110 snd_hdac_ext_stream_decouple(bus, stream, false);
114 list_del(&s->list); 111 list_del(&s->list);
115 kfree(stream); 112 kfree(stream);
116 } 113 }
@@ -119,15 +116,14 @@ EXPORT_SYMBOL_GPL(snd_hdac_stream_free_all);
119 116
120/** 117/**
121 * snd_hdac_ext_stream_decouple - decouple the hdac stream 118 * snd_hdac_ext_stream_decouple - decouple the hdac stream
122 * @ebus: HD-audio ext core bus 119 * @bus: HD-audio core bus
123 * @stream: HD-audio ext core stream object to initialize 120 * @stream: HD-audio ext core stream object to initialize
124 * @decouple: flag to decouple 121 * @decouple: flag to decouple
125 */ 122 */
126void snd_hdac_ext_stream_decouple(struct hdac_ext_bus *ebus, 123void snd_hdac_ext_stream_decouple(struct hdac_bus *bus,
127 struct hdac_ext_stream *stream, bool decouple) 124 struct hdac_ext_stream *stream, bool decouple)
128{ 125{
129 struct hdac_stream *hstream = &stream->hstream; 126 struct hdac_stream *hstream = &stream->hstream;
130 struct hdac_bus *bus = &ebus->bus;
131 u32 val; 127 u32 val;
132 int mask = AZX_PPCTL_PROCEN(hstream->index); 128 int mask = AZX_PPCTL_PROCEN(hstream->index);
133 129
@@ -251,19 +247,18 @@ void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link,
251EXPORT_SYMBOL_GPL(snd_hdac_ext_link_clear_stream_id); 247EXPORT_SYMBOL_GPL(snd_hdac_ext_link_clear_stream_id);
252 248
253static struct hdac_ext_stream * 249static struct hdac_ext_stream *
254hdac_ext_link_stream_assign(struct hdac_ext_bus *ebus, 250hdac_ext_link_stream_assign(struct hdac_bus *bus,
255 struct snd_pcm_substream *substream) 251 struct snd_pcm_substream *substream)
256{ 252{
257 struct hdac_ext_stream *res = NULL; 253 struct hdac_ext_stream *res = NULL;
258 struct hdac_stream *stream = NULL; 254 struct hdac_stream *stream = NULL;
259 struct hdac_bus *hbus = &ebus->bus;
260 255
261 if (!hbus->ppcap) { 256 if (!bus->ppcap) {
262 dev_err(hbus->dev, "stream type not supported\n"); 257 dev_err(bus->dev, "stream type not supported\n");
263 return NULL; 258 return NULL;
264 } 259 }
265 260
266 list_for_each_entry(stream, &hbus->stream_list, list) { 261 list_for_each_entry(stream, &bus->stream_list, list) {
267 struct hdac_ext_stream *hstream = container_of(stream, 262 struct hdac_ext_stream *hstream = container_of(stream,
268 struct hdac_ext_stream, 263 struct hdac_ext_stream,
269 hstream); 264 hstream);
@@ -277,34 +272,33 @@ hdac_ext_link_stream_assign(struct hdac_ext_bus *ebus,
277 } 272 }
278 273
279 if (!hstream->link_locked) { 274 if (!hstream->link_locked) {
280 snd_hdac_ext_stream_decouple(ebus, hstream, true); 275 snd_hdac_ext_stream_decouple(bus, hstream, true);
281 res = hstream; 276 res = hstream;
282 break; 277 break;
283 } 278 }
284 } 279 }
285 if (res) { 280 if (res) {
286 spin_lock_irq(&hbus->reg_lock); 281 spin_lock_irq(&bus->reg_lock);
287 res->link_locked = 1; 282 res->link_locked = 1;
288 res->link_substream = substream; 283 res->link_substream = substream;
289 spin_unlock_irq(&hbus->reg_lock); 284 spin_unlock_irq(&bus->reg_lock);
290 } 285 }
291 return res; 286 return res;
292} 287}
293 288
294static struct hdac_ext_stream * 289static struct hdac_ext_stream *
295hdac_ext_host_stream_assign(struct hdac_ext_bus *ebus, 290hdac_ext_host_stream_assign(struct hdac_bus *bus,
296 struct snd_pcm_substream *substream) 291 struct snd_pcm_substream *substream)
297{ 292{
298 struct hdac_ext_stream *res = NULL; 293 struct hdac_ext_stream *res = NULL;
299 struct hdac_stream *stream = NULL; 294 struct hdac_stream *stream = NULL;
300 struct hdac_bus *hbus = &ebus->bus;
301 295
302 if (!hbus->ppcap) { 296 if (!bus->ppcap) {
303 dev_err(hbus->dev, "stream type not supported\n"); 297 dev_err(bus->dev, "stream type not supported\n");
304 return NULL; 298 return NULL;
305 } 299 }
306 300
307 list_for_each_entry(stream, &hbus->stream_list, list) { 301 list_for_each_entry(stream, &bus->stream_list, list) {
308 struct hdac_ext_stream *hstream = container_of(stream, 302 struct hdac_ext_stream *hstream = container_of(stream,
309 struct hdac_ext_stream, 303 struct hdac_ext_stream,
310 hstream); 304 hstream);
@@ -313,17 +307,17 @@ hdac_ext_host_stream_assign(struct hdac_ext_bus *ebus,
313 307
314 if (!stream->opened) { 308 if (!stream->opened) {
315 if (!hstream->decoupled) 309 if (!hstream->decoupled)
316 snd_hdac_ext_stream_decouple(ebus, hstream, true); 310 snd_hdac_ext_stream_decouple(bus, hstream, true);
317 res = hstream; 311 res = hstream;
318 break; 312 break;
319 } 313 }
320 } 314 }
321 if (res) { 315 if (res) {
322 spin_lock_irq(&hbus->reg_lock); 316 spin_lock_irq(&bus->reg_lock);
323 res->hstream.opened = 1; 317 res->hstream.opened = 1;
324 res->hstream.running = 0; 318 res->hstream.running = 0;
325 res->hstream.substream = substream; 319 res->hstream.substream = substream;
326 spin_unlock_irq(&hbus->reg_lock); 320 spin_unlock_irq(&bus->reg_lock);
327 } 321 }
328 322
329 return res; 323 return res;
@@ -331,7 +325,7 @@ hdac_ext_host_stream_assign(struct hdac_ext_bus *ebus,
331 325
332/** 326/**
333 * snd_hdac_ext_stream_assign - assign a stream for the PCM 327 * snd_hdac_ext_stream_assign - assign a stream for the PCM
334 * @ebus: HD-audio ext core bus 328 * @bus: HD-audio core bus
335 * @substream: PCM substream to assign 329 * @substream: PCM substream to assign
336 * @type: type of stream (coupled, host or link stream) 330 * @type: type of stream (coupled, host or link stream)
337 * 331 *
@@ -346,27 +340,26 @@ hdac_ext_host_stream_assign(struct hdac_ext_bus *ebus,
346 * the same stream object when it's used beforehand. when a stream is 340 * the same stream object when it's used beforehand. when a stream is
347 * decoupled, it becomes a host stream and link stream. 341 * decoupled, it becomes a host stream and link stream.
348 */ 342 */
349struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *ebus, 343struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus,
350 struct snd_pcm_substream *substream, 344 struct snd_pcm_substream *substream,
351 int type) 345 int type)
352{ 346{
353 struct hdac_ext_stream *hstream = NULL; 347 struct hdac_ext_stream *hstream = NULL;
354 struct hdac_stream *stream = NULL; 348 struct hdac_stream *stream = NULL;
355 struct hdac_bus *hbus = &ebus->bus;
356 349
357 switch (type) { 350 switch (type) {
358 case HDAC_EXT_STREAM_TYPE_COUPLED: 351 case HDAC_EXT_STREAM_TYPE_COUPLED:
359 stream = snd_hdac_stream_assign(hbus, substream); 352 stream = snd_hdac_stream_assign(bus, substream);
360 if (stream) 353 if (stream)
361 hstream = container_of(stream, 354 hstream = container_of(stream,
362 struct hdac_ext_stream, hstream); 355 struct hdac_ext_stream, hstream);
363 return hstream; 356 return hstream;
364 357
365 case HDAC_EXT_STREAM_TYPE_HOST: 358 case HDAC_EXT_STREAM_TYPE_HOST:
366 return hdac_ext_host_stream_assign(ebus, substream); 359 return hdac_ext_host_stream_assign(bus, substream);
367 360
368 case HDAC_EXT_STREAM_TYPE_LINK: 361 case HDAC_EXT_STREAM_TYPE_LINK:
369 return hdac_ext_link_stream_assign(ebus, substream); 362 return hdac_ext_link_stream_assign(bus, substream);
370 363
371 default: 364 default:
372 return NULL; 365 return NULL;
@@ -384,7 +377,6 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_assign);
384void snd_hdac_ext_stream_release(struct hdac_ext_stream *stream, int type) 377void snd_hdac_ext_stream_release(struct hdac_ext_stream *stream, int type)
385{ 378{
386 struct hdac_bus *bus = stream->hstream.bus; 379 struct hdac_bus *bus = stream->hstream.bus;
387 struct hdac_ext_bus *ebus = hbus_to_ebus(bus);
388 380
389 switch (type) { 381 switch (type) {
390 case HDAC_EXT_STREAM_TYPE_COUPLED: 382 case HDAC_EXT_STREAM_TYPE_COUPLED:
@@ -393,13 +385,13 @@ void snd_hdac_ext_stream_release(struct hdac_ext_stream *stream, int type)
393 385
394 case HDAC_EXT_STREAM_TYPE_HOST: 386 case HDAC_EXT_STREAM_TYPE_HOST:
395 if (stream->decoupled && !stream->link_locked) 387 if (stream->decoupled && !stream->link_locked)
396 snd_hdac_ext_stream_decouple(ebus, stream, false); 388 snd_hdac_ext_stream_decouple(bus, stream, false);
397 snd_hdac_stream_release(&stream->hstream); 389 snd_hdac_stream_release(&stream->hstream);
398 break; 390 break;
399 391
400 case HDAC_EXT_STREAM_TYPE_LINK: 392 case HDAC_EXT_STREAM_TYPE_LINK:
401 if (stream->decoupled && !stream->hstream.opened) 393 if (stream->decoupled && !stream->hstream.opened)
402 snd_hdac_ext_stream_decouple(ebus, stream, false); 394 snd_hdac_ext_stream_decouple(bus, stream, false);
403 spin_lock_irq(&bus->reg_lock); 395 spin_lock_irq(&bus->reg_lock);
404 stream->link_locked = 0; 396 stream->link_locked = 0;
405 stream->link_substream = NULL; 397 stream->link_substream = NULL;
@@ -415,16 +407,15 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_release);
415 407
416/** 408/**
417 * snd_hdac_ext_stream_spbcap_enable - enable SPIB for a stream 409 * snd_hdac_ext_stream_spbcap_enable - enable SPIB for a stream
418 * @ebus: HD-audio ext core bus 410 * @bus: HD-audio core bus
419 * @enable: flag to enable/disable SPIB 411 * @enable: flag to enable/disable SPIB
420 * @index: stream index for which SPIB need to be enabled 412 * @index: stream index for which SPIB need to be enabled
421 */ 413 */
422void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *ebus, 414void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *bus,
423 bool enable, int index) 415 bool enable, int index)
424{ 416{
425 u32 mask = 0; 417 u32 mask = 0;
426 u32 register_mask = 0; 418 u32 register_mask = 0;
427 struct hdac_bus *bus = &ebus->bus;
428 419
429 if (!bus->spbcap) { 420 if (!bus->spbcap) {
430 dev_err(bus->dev, "Address of SPB capability is NULL\n"); 421 dev_err(bus->dev, "Address of SPB capability is NULL\n");
@@ -446,14 +437,13 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_spbcap_enable);
446 437
447/** 438/**
448 * snd_hdac_ext_stream_set_spib - sets the spib value of a stream 439 * snd_hdac_ext_stream_set_spib - sets the spib value of a stream
449 * @ebus: HD-audio ext core bus 440 * @bus: HD-audio core bus
450 * @stream: hdac_ext_stream 441 * @stream: hdac_ext_stream
451 * @value: spib value to set 442 * @value: spib value to set
452 */ 443 */
453int snd_hdac_ext_stream_set_spib(struct hdac_ext_bus *ebus, 444int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus,
454 struct hdac_ext_stream *stream, u32 value) 445 struct hdac_ext_stream *stream, u32 value)
455{ 446{
456 struct hdac_bus *bus = &ebus->bus;
457 447
458 if (!bus->spbcap) { 448 if (!bus->spbcap) {
459 dev_err(bus->dev, "Address of SPB capability is NULL\n"); 449 dev_err(bus->dev, "Address of SPB capability is NULL\n");
@@ -468,15 +458,14 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_spib);
468 458
469/** 459/**
470 * snd_hdac_ext_stream_get_spbmaxfifo - gets the spib value of a stream 460 * snd_hdac_ext_stream_get_spbmaxfifo - gets the spib value of a stream
471 * @ebus: HD-audio ext core bus 461 * @bus: HD-audio core bus
472 * @stream: hdac_ext_stream 462 * @stream: hdac_ext_stream
473 * 463 *
474 * Return maxfifo for the stream 464 * Return maxfifo for the stream
475 */ 465 */
476int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_ext_bus *ebus, 466int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus,
477 struct hdac_ext_stream *stream) 467 struct hdac_ext_stream *stream)
478{ 468{
479 struct hdac_bus *bus = &ebus->bus;
480 469
481 if (!bus->spbcap) { 470 if (!bus->spbcap) {
482 dev_err(bus->dev, "Address of SPB capability is NULL\n"); 471 dev_err(bus->dev, "Address of SPB capability is NULL\n");
@@ -490,11 +479,10 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_get_spbmaxfifo);
490 479
491/** 480/**
492 * snd_hdac_ext_stop_streams - stop all stream if running 481 * snd_hdac_ext_stop_streams - stop all stream if running
493 * @ebus: HD-audio ext core bus 482 * @bus: HD-audio core bus
494 */ 483 */
495void snd_hdac_ext_stop_streams(struct hdac_ext_bus *ebus) 484void snd_hdac_ext_stop_streams(struct hdac_bus *bus)
496{ 485{
497 struct hdac_bus *bus = ebus_to_hbus(ebus);
498 struct hdac_stream *stream; 486 struct hdac_stream *stream;
499 487
500 if (bus->chip_init) { 488 if (bus->chip_init) {
@@ -507,16 +495,15 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stop_streams);
507 495
508/** 496/**
509 * snd_hdac_ext_stream_drsm_enable - enable DMA resume for a stream 497 * snd_hdac_ext_stream_drsm_enable - enable DMA resume for a stream
510 * @ebus: HD-audio ext core bus 498 * @bus: HD-audio core bus
511 * @enable: flag to enable/disable DRSM 499 * @enable: flag to enable/disable DRSM
512 * @index: stream index for which DRSM need to be enabled 500 * @index: stream index for which DRSM need to be enabled
513 */ 501 */
514void snd_hdac_ext_stream_drsm_enable(struct hdac_ext_bus *ebus, 502void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus,
515 bool enable, int index) 503 bool enable, int index)
516{ 504{
517 u32 mask = 0; 505 u32 mask = 0;
518 u32 register_mask = 0; 506 u32 register_mask = 0;
519 struct hdac_bus *bus = &ebus->bus;
520 507
521 if (!bus->drsmcap) { 508 if (!bus->drsmcap) {
522 dev_err(bus->dev, "Address of DRSM capability is NULL\n"); 509 dev_err(bus->dev, "Address of DRSM capability is NULL\n");
@@ -538,14 +525,13 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_drsm_enable);
538 525
539/** 526/**
540 * snd_hdac_ext_stream_set_dpibr - sets the dpibr value of a stream 527 * snd_hdac_ext_stream_set_dpibr - sets the dpibr value of a stream
541 * @ebus: HD-audio ext core bus 528 * @bus: HD-audio core bus
542 * @stream: hdac_ext_stream 529 * @stream: hdac_ext_stream
543 * @value: dpib value to set 530 * @value: dpib value to set
544 */ 531 */
545int snd_hdac_ext_stream_set_dpibr(struct hdac_ext_bus *ebus, 532int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus,
546 struct hdac_ext_stream *stream, u32 value) 533 struct hdac_ext_stream *stream, u32 value)
547{ 534{
548 struct hdac_bus *bus = &ebus->bus;
549 535
550 if (!bus->drsmcap) { 536 if (!bus->drsmcap) {
551 dev_err(bus->dev, "Address of DRSM capability is NULL\n"); 537 dev_err(bus->dev, "Address of DRSM capability is NULL\n");
@@ -560,7 +546,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_dpibr);
560 546
561/** 547/**
562 * snd_hdac_ext_stream_set_lpib - sets the lpib value of a stream 548 * snd_hdac_ext_stream_set_lpib - sets the lpib value of a stream
563 * @ebus: HD-audio ext core bus 549 * @bus: HD-audio core bus
564 * @stream: hdac_ext_stream 550 * @stream: hdac_ext_stream
565 * @value: lpib value to set 551 * @value: lpib value to set
566 */ 552 */