sound/usb/stream.c
Source file repositories/reference/linux-study-clean/sound/usb/stream.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/stream.c- Extension
.c- Size
- 34044 bytes
- Lines
- 1292
- Domain
- Driver Families
- Bucket
- sound/usb
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/init.hlinux/slab.hlinux/usb.hlinux/usb/audio.hlinux/usb/audio-v2.hlinux/usb/audio-v3.hsound/core.hsound/pcm.hsound/control.hsound/tlv.husbaudio.hcard.hproc.hquirks.hendpoint.hpcm.hhelper.hformat.hclock.hstream.hpower.hmedia.h
Detected Declarations
function audioformat_freefunction free_substreamfunction snd_usb_audio_stream_freefunction snd_usb_audio_pcm_freefunction snd_usb_init_substreamfunction usb_chmap_ctl_infofunction have_dup_chmapfunction list_for_each_entry_continue_reversefunction usb_chmap_ctl_tlvfunction usb_chmap_ctl_getfunction add_chmapfunction snd_usb_add_audio_streamfunction list_for_each_entryfunction parse_uac_endpoint_attributesfunction snd_usb_find_input_terminal_descriptorfunction snd_usb_find_output_terminal_descriptorfunction audio_format_alloc_initfunction snd_usb_get_audioformat_uac12function snd_usb_get_audioformat_uac3function __snd_usb_parse_audio_interfacefunction snd_usb_parse_audio_interface
Annotated Snippet
if (cs_type == UAC3_CHANNEL_INFORMATION) {
struct uac3_cluster_information_segment_descriptor *is = p;
unsigned char map;
if (cs_len < sizeof(*is))
break;
/*
* TODO: this conversion is not complete, update it
* after adding UAC3 values to asound.h
* NOTE: not all UAC3 channel relationship have a
* direct ALSA chmap equivalent.
*/
switch (is->bChRelationship) {
case UAC3_CH_MONO:
map = SNDRV_CHMAP_MONO;
break;
case UAC3_CH_LEFT:
case UAC3_CH_FRONT_LEFT:
case UAC3_CH_HEADPHONE_LEFT:
map = SNDRV_CHMAP_FL;
break;
case UAC3_CH_RIGHT:
case UAC3_CH_FRONT_RIGHT:
case UAC3_CH_HEADPHONE_RIGHT:
map = SNDRV_CHMAP_FR;
break;
case UAC3_CH_FRONT_CENTER:
map = SNDRV_CHMAP_FC;
break;
case UAC3_CH_FRONT_LEFT_OF_CENTER:
map = SNDRV_CHMAP_FLC;
break;
case UAC3_CH_FRONT_RIGHT_OF_CENTER:
map = SNDRV_CHMAP_FRC;
break;
case UAC3_CH_FRONT_WIDE_LEFT:
map = SNDRV_CHMAP_FLW;
break;
case UAC3_CH_FRONT_WIDE_RIGHT:
map = SNDRV_CHMAP_FRW;
break;
case UAC3_CH_SIDE_LEFT:
map = SNDRV_CHMAP_SL;
break;
case UAC3_CH_SIDE_RIGHT:
map = SNDRV_CHMAP_SR;
break;
case UAC3_CH_BACK_LEFT:
map = SNDRV_CHMAP_RL;
break;
case UAC3_CH_BACK_RIGHT:
map = SNDRV_CHMAP_RR;
break;
case UAC3_CH_BACK_CENTER:
map = SNDRV_CHMAP_RC;
break;
case UAC3_CH_BACK_LEFT_OF_CENTER:
map = SNDRV_CHMAP_RLC;
break;
case UAC3_CH_BACK_RIGHT_OF_CENTER:
map = SNDRV_CHMAP_RRC;
break;
case UAC3_CH_TOP_CENTER:
map = SNDRV_CHMAP_TC;
break;
case UAC3_CH_TOP_FRONT_LEFT:
map = SNDRV_CHMAP_TFL;
break;
case UAC3_CH_TOP_FRONT_RIGHT:
map = SNDRV_CHMAP_TFR;
break;
case UAC3_CH_TOP_FRONT_CENTER:
map = SNDRV_CHMAP_TFC;
break;
case UAC3_CH_TOP_FRONT_LOC:
map = SNDRV_CHMAP_TFLC;
break;
case UAC3_CH_TOP_FRONT_ROC:
map = SNDRV_CHMAP_TFRC;
break;
case UAC3_CH_TOP_SIDE_LEFT:
map = SNDRV_CHMAP_TSL;
break;
case UAC3_CH_TOP_SIDE_RIGHT:
map = SNDRV_CHMAP_TSR;
break;
case UAC3_CH_TOP_BACK_LEFT:
map = SNDRV_CHMAP_TRL;
break;
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `linux/usb.h`, `linux/usb/audio.h`, `linux/usb/audio-v2.h`, `linux/usb/audio-v3.h`, `sound/core.h`, `sound/pcm.h`.
- Detected declarations: `function audioformat_free`, `function free_substream`, `function snd_usb_audio_stream_free`, `function snd_usb_audio_pcm_free`, `function snd_usb_init_substream`, `function usb_chmap_ctl_info`, `function have_dup_chmap`, `function list_for_each_entry_continue_reverse`, `function usb_chmap_ctl_tlv`, `function usb_chmap_ctl_get`.
- Atlas domain: Driver Families / sound/usb.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.