sound/hda/core/stream.c
Source file repositories/reference/linux-study-clean/sound/hda/core/stream.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/core/stream.c- Extension
.c- Size
- 27552 bytes
- Lines
- 1005
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/kernel.hlinux/delay.hlinux/export.hlinux/clocksource.hsound/compress_driver.hsound/core.hsound/pcm.hsound/hdaudio.hsound/hda_register.htrace.h
Detected Declarations
function stream_initfunction streamfunction snd_hdac_stream_startfunction snd_hdac_stream_clearfunction snd_hdac_stream_stopfunction snd_hdac_stop_streamsfunction snd_hdac_stop_streams_and_chipfunction snd_hdac_stream_resetfunction snd_hdac_stream_setupfunction snd_hdac_stream_cleanupfunction snd_hdac_stream_assignfunction snd_hdac_stream_assignfunction list_for_each_entryfunction setup_bdlefunction snd_hdac_stream_setup_bdlefunction snd_hdac_stream_setup_periodsfunction snd_hdac_stream_set_paramsfunction azx_cc_readfunction azx_timecounter_initfunction flagsfunction list_for_each_entryfunction snd_hdac_stream_sync_triggerfunction snd_hdac_stream_syncfunction list_for_each_entryfunction snd_hdac_stream_spbcap_enablefunction snd_hdac_stream_set_spibfunction snd_hdac_stream_drsm_enablefunction snd_hdac_stream_wait_drsmfunction snd_hdac_stream_set_dpibrfunction snd_hdac_stream_set_lpibfunction snd_hdac_dsp_preparefunction snd_hdac_dsp_triggerfunction snd_hdac_dsp_cleanupexport snd_hdac_get_stream_stripe_ctlexport snd_hdac_stream_initexport snd_hdac_stream_startexport snd_hdac_stream_stopexport snd_hdac_stop_streamsexport snd_hdac_stop_streams_and_chipexport snd_hdac_stream_resetexport snd_hdac_stream_setupexport snd_hdac_stream_cleanupexport snd_hdac_stream_assignexport snd_hdac_stream_release_lockedexport snd_hdac_stream_releaseexport snd_hdac_get_streamexport snd_hdac_stream_setup_periodsexport snd_hdac_stream_set_params
Annotated Snippet
if (azx_dev->assigned_key == key) {
res = azx_dev;
break;
}
if (!res || bus->reverse_assign)
res = azx_dev;
}
if (res) {
res->opened = 1;
res->running = 0;
res->assigned_key = key;
res->substream = substream;
}
return res;
}
EXPORT_SYMBOL_GPL(snd_hdac_stream_assign);
/**
* snd_hdac_stream_release_locked - release the assigned stream
* @azx_dev: HD-audio core stream to release
*
* Release the stream that has been assigned by snd_hdac_stream_assign().
* The bus->reg_lock needs to be taken at a higher level
*/
void snd_hdac_stream_release_locked(struct hdac_stream *azx_dev)
{
azx_dev->opened = 0;
azx_dev->running = 0;
azx_dev->substream = NULL;
}
EXPORT_SYMBOL_GPL(snd_hdac_stream_release_locked);
/**
* snd_hdac_stream_release - release the assigned stream
* @azx_dev: HD-audio core stream to release
*
* Release the stream that has been assigned by snd_hdac_stream_assign().
*/
void snd_hdac_stream_release(struct hdac_stream *azx_dev)
{
struct hdac_bus *bus = azx_dev->bus;
guard(spinlock_irq)(&bus->reg_lock);
snd_hdac_stream_release_locked(azx_dev);
}
EXPORT_SYMBOL_GPL(snd_hdac_stream_release);
/**
* snd_hdac_get_stream - return hdac_stream based on stream_tag and
* direction
*
* @bus: HD-audio core bus
* @dir: direction for the stream to be found
* @stream_tag: stream tag for stream to be found
*/
struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus,
int dir, int stream_tag)
{
struct hdac_stream *s;
list_for_each_entry(s, &bus->stream_list, list) {
if (s->direction == dir && s->stream_tag == stream_tag)
return s;
}
return NULL;
}
EXPORT_SYMBOL_GPL(snd_hdac_get_stream);
/*
* set up a BDL entry
*/
static int setup_bdle(struct hdac_bus *bus,
struct snd_dma_buffer *dmab,
struct hdac_stream *azx_dev, __le32 **bdlp,
int ofs, int size, int with_ioc)
{
__le32 *bdl = *bdlp;
while (size > 0) {
dma_addr_t addr;
int chunk;
if (azx_dev->frags >= AZX_MAX_BDL_ENTRIES)
return -EINVAL;
addr = snd_sgbuf_get_addr(dmab, ofs);
/* program the address field of the BDL entry */
bdl[0] = cpu_to_le32((u32)(addr + bus->addr_offset));
bdl[1] = cpu_to_le32(upper_32_bits(addr + bus->addr_offset));
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/delay.h`, `linux/export.h`, `linux/clocksource.h`, `sound/compress_driver.h`, `sound/core.h`, `sound/pcm.h`, `sound/hdaudio.h`.
- Detected declarations: `function stream_init`, `function stream`, `function snd_hdac_stream_start`, `function snd_hdac_stream_clear`, `function snd_hdac_stream_stop`, `function snd_hdac_stop_streams`, `function snd_hdac_stop_streams_and_chip`, `function snd_hdac_stream_reset`, `function snd_hdac_stream_setup`, `function snd_hdac_stream_cleanup`.
- Atlas domain: Driver Families / sound/hda.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.