sound/hda/core/ext/stream.c
Source file repositories/reference/linux-study-clean/sound/hda/core/ext/stream.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/core/ext/stream.c- Extension
.c- Size
- 12664 bytes
- Lines
- 449
- Domain
- Driver Families
- Bucket
- sound/hda
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/pci.hlinux/pci_ids.hlinux/slab.hsound/pcm.hsound/hda_register.hsound/hdaudio_ext.hsound/compress_driver.h
Detected Declarations
function Copyrightfunction snd_hdac_apl_host_stream_setupfunction snd_hdac_ext_stream_initfunction snd_hdac_ext_stream_init_allfunction snd_hdac_ext_stream_free_allfunction list_for_each_entry_safefunction snd_hdac_ext_stream_decouple_lockedfunction snd_hdac_ext_stream_decouplefunction snd_hdac_ext_stream_startfunction snd_hdac_ext_stream_clearfunction snd_hdac_ext_stream_resetfunction snd_hdac_ext_stream_setupfunction hdac_ext_link_dma_stream_assignfunction hdac_ext_host_dma_stream_assignfunction typefunction snd_hdac_ext_stream_assignfunction scoped_guardfunction scoped_guardexport snd_hdac_ext_host_stream_setupexport snd_hdac_ext_stream_init_allexport snd_hdac_ext_stream_free_allexport snd_hdac_ext_stream_decouple_lockedexport snd_hdac_ext_stream_decoupleexport snd_hdac_ext_stream_startexport snd_hdac_ext_stream_clearexport snd_hdac_ext_stream_resetexport snd_hdac_ext_stream_setupexport snd_hdac_ext_stream_assignexport snd_hdac_ext_stream_releaseexport snd_hdac_ext_cstream_assign
Annotated Snippet
if (!hext_stream->link_locked) {
res = hext_stream;
break;
}
}
if (res) {
snd_hdac_ext_stream_decouple_locked(bus, res, true);
res->link_locked = 1;
res->link_substream = substream;
}
return res;
}
static struct hdac_ext_stream *
hdac_ext_host_dma_stream_assign(struct hdac_bus *bus,
struct snd_pcm_substream *substream)
{
struct hdac_ext_stream *res = NULL;
struct hdac_stream *hstream = NULL;
if (!bus->ppcap) {
dev_err(bus->dev, "stream type not supported\n");
return NULL;
}
guard(spinlock_irq)(&bus->reg_lock);
list_for_each_entry(hstream, &bus->stream_list, list) {
struct hdac_ext_stream *hext_stream = container_of(hstream,
struct hdac_ext_stream,
hstream);
if (hstream->direction != substream->stream)
continue;
if (!hstream->opened) {
res = hext_stream;
break;
}
}
if (res) {
snd_hdac_ext_stream_decouple_locked(bus, res, true);
res->hstream.opened = 1;
res->hstream.running = 0;
res->hstream.substream = substream;
}
return res;
}
/**
* snd_hdac_ext_stream_assign - assign a stream for the PCM
* @bus: HD-audio core bus
* @substream: PCM substream to assign
* @type: type of stream (coupled, host or link stream)
*
* This assigns the stream based on the type (coupled/host/link), for the
* given PCM substream, assigns it and returns the stream object
*
* coupled: Looks for an unused stream
* host: Looks for an unused decoupled host stream
* link: Looks for an unused decoupled link stream
*
* If no stream is free, returns NULL. The function tries to keep using
* the same stream object when it's used beforehand. when a stream is
* decoupled, it becomes a host stream and link stream.
*/
struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus,
struct snd_pcm_substream *substream,
int type)
{
struct hdac_ext_stream *hext_stream = NULL;
struct hdac_stream *hstream = NULL;
switch (type) {
case HDAC_EXT_STREAM_TYPE_COUPLED:
hstream = snd_hdac_stream_assign(bus, substream);
if (hstream)
hext_stream = container_of(hstream,
struct hdac_ext_stream,
hstream);
return hext_stream;
case HDAC_EXT_STREAM_TYPE_HOST:
return hdac_ext_host_dma_stream_assign(bus, substream);
case HDAC_EXT_STREAM_TYPE_LINK:
return hdac_ext_link_dma_stream_assign(bus, substream);
default:
return NULL;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/pci.h`, `linux/pci_ids.h`, `linux/slab.h`, `sound/pcm.h`, `sound/hda_register.h`, `sound/hdaudio_ext.h`, `sound/compress_driver.h`.
- Detected declarations: `function Copyright`, `function snd_hdac_apl_host_stream_setup`, `function snd_hdac_ext_stream_init`, `function snd_hdac_ext_stream_init_all`, `function snd_hdac_ext_stream_free_all`, `function list_for_each_entry_safe`, `function snd_hdac_ext_stream_decouple_locked`, `function snd_hdac_ext_stream_decouple`, `function snd_hdac_ext_stream_start`, `function snd_hdac_ext_stream_clear`.
- Atlas domain: Driver Families / sound/hda.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.