sound/usb/proc.c
Source file repositories/reference/linux-study-clean/sound/usb/proc.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/proc.c- Extension
.c- Size
- 7425 bytes
- Lines
- 237
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/usb.hsound/core.hsound/info.hsound/pcm.husbaudio.hhelper.hcard.hendpoint.hproc.h
Detected Declarations
function get_full_speed_hzfunction get_high_speed_hzfunction proc_audio_usbbus_readfunction proc_audio_usbid_readfunction snd_usb_audio_create_procfunction proc_dump_substream_formatsfunction list_for_each_entryfunction proc_dump_ep_statusfunction proc_dump_substream_statusfunction proc_pcm_format_readfunction snd_usb_proc_pcm_format_add
Annotated Snippet
if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) {
snd_iprintf(buffer, " Rates: %d - %d (continuous)\n",
fp->rate_min, fp->rate_max);
} else {
unsigned int i;
snd_iprintf(buffer, " Rates: ");
for (i = 0; i < fp->nr_rates; i++) {
if (i > 0)
snd_iprintf(buffer, ", ");
snd_iprintf(buffer, "%d", fp->rate_table[i]);
}
snd_iprintf(buffer, "\n");
}
if (subs->speed != USB_SPEED_FULL)
snd_iprintf(buffer, " Data packet interval: %d us\n",
125 * (1 << fp->datainterval));
snd_iprintf(buffer, " Bits: %d\n", fp->fmt_bits);
if (fp->dsd_raw)
snd_iprintf(buffer, " DSD raw: DOP=%d, bitrev=%d\n",
fp->dsd_dop, fp->dsd_bitrev);
if (fp->chmap) {
const struct snd_pcm_chmap_elem *map = fp->chmap;
int c;
snd_iprintf(buffer, " Channel map:");
for (c = 0; c < map->channels; c++) {
if (map->map[c] >= ARRAY_SIZE(channel_labels) ||
!channel_labels[map->map[c]])
snd_iprintf(buffer, " --");
else
snd_iprintf(buffer, " %s",
channel_labels[map->map[c]]);
}
snd_iprintf(buffer, "\n");
}
if (fp->sync_ep) {
snd_iprintf(buffer, " Sync Endpoint: 0x%02x (%d %s)\n",
fp->sync_ep,
fp->sync_ep & USB_ENDPOINT_NUMBER_MASK,
fp->sync_ep & USB_DIR_IN ? "IN" : "OUT");
snd_iprintf(buffer, " Sync EP Interface: %d\n",
fp->sync_iface);
snd_iprintf(buffer, " Sync EP Altset: %d\n",
fp->sync_altsetting);
snd_iprintf(buffer, " Implicit Feedback Mode: %s\n",
fp->implicit_fb ? "Yes" : "No");
}
// snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize);
// snd_iprintf(buffer, " EP Attribute = %#x\n", fp->attributes);
}
}
static void proc_dump_ep_status(struct snd_usb_substream *subs,
struct snd_usb_endpoint *data_ep,
struct snd_usb_endpoint *sync_ep,
struct snd_info_buffer *buffer)
{
if (!data_ep)
return;
snd_iprintf(buffer, " Packet Size = %d\n", data_ep->curpacksize);
snd_iprintf(buffer, " Momentary freq = %u Hz (%#x.%04x)\n",
subs->speed == USB_SPEED_FULL
? get_full_speed_hz(data_ep->freqm)
: get_high_speed_hz(data_ep->freqm),
data_ep->freqm >> 16, data_ep->freqm & 0xffff);
if (sync_ep && data_ep->freqshift != INT_MIN) {
int res = 16 - data_ep->freqshift;
snd_iprintf(buffer, " Feedback Format = %d.%d\n",
(sync_ep->syncmaxsize > 3 ? 32 : 24) - res, res);
}
}
static void proc_dump_substream_status(struct snd_usb_audio *chip,
struct snd_usb_substream *subs,
struct snd_info_buffer *buffer)
{
guard(mutex)(&chip->mutex);
if (subs->running) {
snd_iprintf(buffer, " Status: Running\n");
if (subs->cur_audiofmt) {
snd_iprintf(buffer, " Interface = %d\n", subs->cur_audiofmt->iface);
snd_iprintf(buffer, " Altset = %d\n", subs->cur_audiofmt->altsetting);
}
proc_dump_ep_status(subs, subs->data_endpoint, subs->sync_endpoint, buffer);
} else {
snd_iprintf(buffer, " Status: Stop\n");
Annotation
- Immediate include surface: `linux/init.h`, `linux/usb.h`, `sound/core.h`, `sound/info.h`, `sound/pcm.h`, `usbaudio.h`, `helper.h`, `card.h`.
- Detected declarations: `function get_full_speed_hz`, `function get_high_speed_hz`, `function proc_audio_usbbus_read`, `function proc_audio_usbid_read`, `function snd_usb_audio_create_proc`, `function proc_dump_substream_formats`, `function list_for_each_entry`, `function proc_dump_ep_status`, `function proc_dump_substream_status`, `function proc_pcm_format_read`.
- Atlas domain: Driver Families / sound/usb.
- Implementation status: source implementation candidate.
- 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.