torvalds/linux
Sound
Purpose
sound/ is the ALSA (Advanced Linux Sound Architecture) subsystem: PCM playback/capture, MIDI, mixers, control surfaces, sequencer, plus the ASoC (ALSA System on Chip) framework for embedded audio.
Directory layout
sound/
├── core/ # Card, PCM, control, timer, sequencer, RawMIDI, jack
├── usb/ # USB audio class drivers
├── pci/ # PCI sound cards: hda/, ymfpci/, emu10k1/, ice1712/, …
├── pcmcia/, isa/, parisc/, sparc/, mips/, ppc/, sh/ # Bus/legacy
├── soc/ # ASoC: SoC + codec + machine drivers
├── hda/ # HDA (Intel HDA) shared code
├── synth/, drivers/ # Synth chips, miscellaneous
├── firewire/ # FireWire audio
├── x86/ # x86-only audio glue (HDMI sleep state, etc.)
├── aoa/ # PowerMac AOA framework
├── virtio/ # Virtio sound device
├── sh/, sparc/ # Per-arch sound bits
├── oss/ # OSS compatibility layer (limited)
└── soc/ # ASoC, the largest single sub-area todayKey abstractions
| Symbol | File | Purpose |
|---|---|---|
struct snd_card |
include/sound/core.h |
A logical sound card. |
struct snd_pcm, snd_pcm_substream |
include/sound/pcm.h |
PCM stream — ring buffer between user and hw. |
struct snd_kcontrol |
include/sound/control.h |
A control element (volume, mux, switch). |
struct snd_rawmidi, snd_seq_* |
include/sound/rawmidi.h, seq*.h |
RawMIDI and sequencer. |
struct snd_soc_card, snd_soc_dai, snd_soc_codec, snd_soc_dai_link |
include/sound/soc.h |
ASoC building blocks. |
struct hda_codec |
include/sound/hda_codec.h |
HDA codec descriptor. |
How it works
graph LR
APP[User-space app via /dev/snd/*] --> ALSA[core/ ALSA core]
ALSA --> CARD[snd_card]
CARD --> PCM[snd_pcm]
CARD --> CTL[snd_kcontrol]
CARD --> RAW[snd_rawmidi]
PCM -->|hw_ops| DRV1["pci/hda/ or usb/ or soc/"]
DRV1 --> HW[Hardware]
SOC["soc/ ASoC machine"] --> CODEC["soc/codecs/"]
SOC --> CPU_DAI["soc/<vendor>/ CPU DAI"]A driver registers a snd_card, populates it with PCMs and controls, and provides snd_pcm_ops (open, hw_params, prepare, trigger, pointer). User space talks to /dev/snd/pcmCxDxp (playback) / pcmCxDxc (capture) and /dev/snd/controlCx (mixer).
ASoC composes a "machine" from a CPU DAI (the SoC audio peripheral) plus one or more codec DAIs (chips that drive speakers/mics). The machine driver describes the wiring; the framework runs the streaming.
Integration points
- drivers/: the underlying buses (PCI, USB, I2C, SPI, platform).
- fs/: the
snd-*char devices via the ALSA core. - mm/: PCM buffers may be allocated via DMA mapping.
- kernel/: ftrace events for ASoC.
Key source files
| File | Purpose |
|---|---|
sound/core/sound.c |
snd_card lifecycle. |
sound/core/pcm_native.c |
The big PCM state machine. |
sound/core/control.c |
Mixer controls. |
sound/soc/soc-core.c |
ASoC core. |
sound/pci/hda/hda_codec.c |
HDA codec layer. |
Entry points for modification
- New PCI/USB sound card: add a driver under
sound/pci/<vendor>/orsound/usb/. Most just registersnd_cardand PCMs. - New ASoC codec:
sound/soc/codecs/<chip>.c— implementsnd_soc_codec_driverand DAI ops. - New ASoC platform:
sound/soc/<vendor>/<soc>/for the I2S/TDM/PDM peripheral.
Related pages
- Drivers — bus drivers used by sound.
- Memory management — DMA mapping for PCM buffers.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.