| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * hdac-ext-stream.c - HD-audio extended stream operations. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2015 Intel Corp |
|---|
| 5 | 6 | * Author: Jeeja KP <jeeja.kp@intel.com> |
|---|
| 6 | 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 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. |
|---|
| 16 | 8 | * |
|---|
| 17 | 9 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 18 | 10 | */ |
|---|
| .. | .. |
|---|
| 114 | 106 | } |
|---|
| 115 | 107 | EXPORT_SYMBOL_GPL(snd_hdac_stream_free_all); |
|---|
| 116 | 108 | |
|---|
| 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) |
|---|
| 125 | 112 | { |
|---|
| 126 | 113 | struct hdac_stream *hstream = &stream->hstream; |
|---|
| 127 | 114 | u32 val; |
|---|
| 128 | 115 | int mask = AZX_PPCTL_PROCEN(hstream->index); |
|---|
| 129 | 116 | |
|---|
| 130 | | - spin_lock_irq(&bus->reg_lock); |
|---|
| 131 | 117 | val = readw(bus->ppcap + AZX_REG_PP_PPCTL) & mask; |
|---|
| 132 | 118 | |
|---|
| 133 | 119 | if (decouple && !val) |
|---|
| .. | .. |
|---|
| 136 | 122 | snd_hdac_updatel(bus->ppcap, AZX_REG_PP_PPCTL, mask, 0); |
|---|
| 137 | 123 | |
|---|
| 138 | 124 | 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); |
|---|
| 139 | 139 | spin_unlock_irq(&bus->reg_lock); |
|---|
| 140 | 140 | } |
|---|
| 141 | 141 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple); |
|---|
| .. | .. |
|---|
| 260 | 260 | return NULL; |
|---|
| 261 | 261 | } |
|---|
| 262 | 262 | |
|---|
| 263 | + spin_lock_irq(&bus->reg_lock); |
|---|
| 263 | 264 | list_for_each_entry(stream, &bus->stream_list, list) { |
|---|
| 264 | 265 | struct hdac_ext_stream *hstream = container_of(stream, |
|---|
| 265 | 266 | struct hdac_ext_stream, |
|---|
| .. | .. |
|---|
| 274 | 275 | } |
|---|
| 275 | 276 | |
|---|
| 276 | 277 | if (!hstream->link_locked) { |
|---|
| 277 | | - snd_hdac_ext_stream_decouple(bus, hstream, true); |
|---|
| 278 | + snd_hdac_ext_stream_decouple_locked(bus, hstream, true); |
|---|
| 278 | 279 | res = hstream; |
|---|
| 279 | 280 | break; |
|---|
| 280 | 281 | } |
|---|
| 281 | 282 | } |
|---|
| 282 | 283 | if (res) { |
|---|
| 283 | | - spin_lock_irq(&bus->reg_lock); |
|---|
| 284 | 284 | res->link_locked = 1; |
|---|
| 285 | 285 | res->link_substream = substream; |
|---|
| 286 | | - spin_unlock_irq(&bus->reg_lock); |
|---|
| 287 | 286 | } |
|---|
| 287 | + spin_unlock_irq(&bus->reg_lock); |
|---|
| 288 | 288 | return res; |
|---|
| 289 | 289 | } |
|---|
| 290 | 290 | |
|---|
| .. | .. |
|---|
| 300 | 300 | return NULL; |
|---|
| 301 | 301 | } |
|---|
| 302 | 302 | |
|---|
| 303 | + spin_lock_irq(&bus->reg_lock); |
|---|
| 303 | 304 | list_for_each_entry(stream, &bus->stream_list, list) { |
|---|
| 304 | 305 | struct hdac_ext_stream *hstream = container_of(stream, |
|---|
| 305 | 306 | struct hdac_ext_stream, |
|---|
| .. | .. |
|---|
| 309 | 310 | |
|---|
| 310 | 311 | if (!stream->opened) { |
|---|
| 311 | 312 | if (!hstream->decoupled) |
|---|
| 312 | | - snd_hdac_ext_stream_decouple(bus, hstream, true); |
|---|
| 313 | + snd_hdac_ext_stream_decouple_locked(bus, hstream, true); |
|---|
| 313 | 314 | res = hstream; |
|---|
| 314 | 315 | break; |
|---|
| 315 | 316 | } |
|---|
| 316 | 317 | } |
|---|
| 317 | 318 | if (res) { |
|---|
| 318 | | - spin_lock_irq(&bus->reg_lock); |
|---|
| 319 | 319 | res->hstream.opened = 1; |
|---|
| 320 | 320 | res->hstream.running = 0; |
|---|
| 321 | 321 | res->hstream.substream = substream; |
|---|
| 322 | | - spin_unlock_irq(&bus->reg_lock); |
|---|
| 323 | 322 | } |
|---|
| 323 | + spin_unlock_irq(&bus->reg_lock); |
|---|
| 324 | 324 | |
|---|
| 325 | 325 | return res; |
|---|
| 326 | 326 | } |
|---|
| .. | .. |
|---|
| 386 | 386 | break; |
|---|
| 387 | 387 | |
|---|
| 388 | 388 | case HDAC_EXT_STREAM_TYPE_HOST: |
|---|
| 389 | + spin_lock_irq(&bus->reg_lock); |
|---|
| 389 | 390 | 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); |
|---|
| 391 | 393 | snd_hdac_stream_release(&stream->hstream); |
|---|
| 392 | 394 | break; |
|---|
| 393 | 395 | |
|---|
| 394 | 396 | case HDAC_EXT_STREAM_TYPE_LINK: |
|---|
| 395 | | - if (stream->decoupled && !stream->hstream.opened) |
|---|
| 396 | | - snd_hdac_ext_stream_decouple(bus, stream, false); |
|---|
| 397 | 397 | spin_lock_irq(&bus->reg_lock); |
|---|
| 398 | + if (stream->decoupled && !stream->hstream.opened) |
|---|
| 399 | + snd_hdac_ext_stream_decouple_locked(bus, stream, false); |
|---|
| 398 | 400 | stream->link_locked = 0; |
|---|
| 399 | 401 | stream->link_substream = NULL; |
|---|
| 400 | 402 | spin_unlock_irq(&bus->reg_lock); |
|---|
| .. | .. |
|---|
| 538 | 540 | |
|---|
| 539 | 541 | /** |
|---|
| 540 | 542 | * snd_hdac_ext_stream_set_lpib - sets the lpib value of a stream |
|---|
| 541 | | - * @bus: HD-audio core bus |
|---|
| 542 | 543 | * @stream: hdac_ext_stream |
|---|
| 543 | 544 | * @value: lpib value to set |
|---|
| 544 | 545 | */ |
|---|