forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/hda/ext/hdac_ext_stream.c
....@@ -1,18 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * hdac-ext-stream.c - HD-audio extended stream operations.
34 *
45 * Copyright (C) 2015 Intel Corp
56 * Author: Jeeja KP <jeeja.kp@intel.com>
67 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; version 2 of the License.
11
- *
12
- * This program is distributed in the hope that it will be useful, but
13
- * WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- * General Public License for more details.
168 *
179 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1810 */
....@@ -114,20 +106,14 @@
114106 }
115107 EXPORT_SYMBOL_GPL(snd_hdac_stream_free_all);
116108
117
-/**
118
- * snd_hdac_ext_stream_decouple - decouple the hdac stream
119
- * @bus: HD-audio core bus
120
- * @stream: HD-audio ext core stream object to initialize
121
- * @decouple: flag to decouple
122
- */
123
-void snd_hdac_ext_stream_decouple(struct hdac_bus *bus,
124
- struct hdac_ext_stream *stream, bool decouple)
109
+void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus,
110
+ struct hdac_ext_stream *stream,
111
+ bool decouple)
125112 {
126113 struct hdac_stream *hstream = &stream->hstream;
127114 u32 val;
128115 int mask = AZX_PPCTL_PROCEN(hstream->index);
129116
130
- spin_lock_irq(&bus->reg_lock);
131117 val = readw(bus->ppcap + AZX_REG_PP_PPCTL) & mask;
132118
133119 if (decouple && !val)
....@@ -136,6 +122,20 @@
136122 snd_hdac_updatel(bus->ppcap, AZX_REG_PP_PPCTL, mask, 0);
137123
138124 stream->decoupled = decouple;
125
+}
126
+EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple_locked);
127
+
128
+/**
129
+ * snd_hdac_ext_stream_decouple - decouple the hdac stream
130
+ * @bus: HD-audio core bus
131
+ * @stream: HD-audio ext core stream object to initialize
132
+ * @decouple: flag to decouple
133
+ */
134
+void snd_hdac_ext_stream_decouple(struct hdac_bus *bus,
135
+ struct hdac_ext_stream *stream, bool decouple)
136
+{
137
+ spin_lock_irq(&bus->reg_lock);
138
+ snd_hdac_ext_stream_decouple_locked(bus, stream, decouple);
139139 spin_unlock_irq(&bus->reg_lock);
140140 }
141141 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple);
....@@ -260,6 +260,7 @@
260260 return NULL;
261261 }
262262
263
+ spin_lock_irq(&bus->reg_lock);
263264 list_for_each_entry(stream, &bus->stream_list, list) {
264265 struct hdac_ext_stream *hstream = container_of(stream,
265266 struct hdac_ext_stream,
....@@ -274,17 +275,16 @@
274275 }
275276
276277 if (!hstream->link_locked) {
277
- snd_hdac_ext_stream_decouple(bus, hstream, true);
278
+ snd_hdac_ext_stream_decouple_locked(bus, hstream, true);
278279 res = hstream;
279280 break;
280281 }
281282 }
282283 if (res) {
283
- spin_lock_irq(&bus->reg_lock);
284284 res->link_locked = 1;
285285 res->link_substream = substream;
286
- spin_unlock_irq(&bus->reg_lock);
287286 }
287
+ spin_unlock_irq(&bus->reg_lock);
288288 return res;
289289 }
290290
....@@ -300,6 +300,7 @@
300300 return NULL;
301301 }
302302
303
+ spin_lock_irq(&bus->reg_lock);
303304 list_for_each_entry(stream, &bus->stream_list, list) {
304305 struct hdac_ext_stream *hstream = container_of(stream,
305306 struct hdac_ext_stream,
....@@ -309,18 +310,17 @@
309310
310311 if (!stream->opened) {
311312 if (!hstream->decoupled)
312
- snd_hdac_ext_stream_decouple(bus, hstream, true);
313
+ snd_hdac_ext_stream_decouple_locked(bus, hstream, true);
313314 res = hstream;
314315 break;
315316 }
316317 }
317318 if (res) {
318
- spin_lock_irq(&bus->reg_lock);
319319 res->hstream.opened = 1;
320320 res->hstream.running = 0;
321321 res->hstream.substream = substream;
322
- spin_unlock_irq(&bus->reg_lock);
323322 }
323
+ spin_unlock_irq(&bus->reg_lock);
324324
325325 return res;
326326 }
....@@ -386,15 +386,17 @@
386386 break;
387387
388388 case HDAC_EXT_STREAM_TYPE_HOST:
389
+ spin_lock_irq(&bus->reg_lock);
389390 if (stream->decoupled && !stream->link_locked)
390
- snd_hdac_ext_stream_decouple(bus, stream, false);
391
+ snd_hdac_ext_stream_decouple_locked(bus, stream, false);
392
+ spin_unlock_irq(&bus->reg_lock);
391393 snd_hdac_stream_release(&stream->hstream);
392394 break;
393395
394396 case HDAC_EXT_STREAM_TYPE_LINK:
395
- if (stream->decoupled && !stream->hstream.opened)
396
- snd_hdac_ext_stream_decouple(bus, stream, false);
397397 spin_lock_irq(&bus->reg_lock);
398
+ if (stream->decoupled && !stream->hstream.opened)
399
+ snd_hdac_ext_stream_decouple_locked(bus, stream, false);
398400 stream->link_locked = 0;
399401 stream->link_substream = NULL;
400402 spin_unlock_irq(&bus->reg_lock);
....@@ -538,7 +540,6 @@
538540
539541 /**
540542 * snd_hdac_ext_stream_set_lpib - sets the lpib value of a stream
541
- * @bus: HD-audio core bus
542543 * @stream: hdac_ext_stream
543544 * @value: lpib value to set
544545 */