sound/pci/ymfpci/ymfpci_main.c
Source file repositories/reference/linux-study-clean/sound/pci/ymfpci/ymfpci_main.c
File Facts
- System
- Linux kernel
- Corpus path
sound/pci/ymfpci/ymfpci_main.c- Extension
.c- Size
- 68232 bytes
- Lines
- 2318
- Domain
- Driver Families
- Bucket
- sound/pci
- 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.
- 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/delay.hlinux/firmware.hlinux/init.hlinux/interrupt.hlinux/pci.hlinux/sched.hlinux/slab.hlinux/mutex.hlinux/module.hlinux/io.hsound/core.hsound/control.hsound/info.hsound/tlv.hymfpci.hsound/asoundef.hsound/mpu401.hasm/byteorder.h
Detected Declarations
function snd_ymfpci_writebfunction snd_ymfpci_readwfunction snd_ymfpci_writewfunction snd_ymfpci_readlfunction snd_ymfpci_writelfunction snd_ymfpci_codec_readyfunction snd_ymfpci_codec_writefunction snd_ymfpci_codec_readfunction snd_ymfpci_calc_deltafunction snd_ymfpci_calc_lpfKfunction snd_ymfpci_calc_lpfQfunction snd_ymfpci_hw_startfunction snd_ymfpci_hw_stopfunction voice_allocfunction snd_ymfpci_voice_allocfunction snd_ymfpci_voice_freefunction snd_ymfpci_pcm_interruptfunction snd_ymfpci_pcm_capture_interruptfunction snd_ymfpci_playback_triggerfunction snd_ymfpci_capture_triggerfunction snd_ymfpci_pcm_voice_allocfunction snd_ymfpci_pcm_init_voicefunction snd_ymfpci_ac3_initfunction snd_ymfpci_ac3_donefunction snd_ymfpci_playback_hw_paramsfunction snd_ymfpci_playback_hw_freefunction snd_ymfpci_playback_preparefunction snd_ymfpci_capture_hw_freefunction snd_ymfpci_capture_preparefunction snd_ymfpci_playback_pointerfunction snd_ymfpci_capture_pointerfunction snd_ymfpci_irq_waitfunction snd_ymfpci_interruptfunction scoped_guardfunction scoped_guardfunction snd_ymfpci_pcm_free_substreamfunction snd_ymfpci_playback_open_1function ymfpci_open_extensionfunction ymfpci_close_extensionfunction snd_ymfpci_playback_openfunction snd_ymfpci_playback_spdif_openfunction snd_ymfpci_playback_4ch_openfunction snd_ymfpci_capture_openfunction snd_ymfpci_capture_rec_openfunction snd_ymfpci_capture_ac97_openfunction snd_ymfpci_playback_close_1function snd_ymfpci_playback_closefunction scoped_guard
Annotated Snippet
switch (type) {
case YMFPCI_PCM:
voice->pcm = 1;
if (voice2)
voice2->pcm = 1;
break;
case YMFPCI_SYNTH:
voice->synth = 1;
break;
case YMFPCI_MIDI:
voice->midi = 1;
break;
}
snd_ymfpci_hw_start(chip);
if (voice2)
snd_ymfpci_hw_start(chip);
*rvoice = voice;
return 0;
}
return -ENOMEM;
}
static int snd_ymfpci_voice_alloc(struct snd_ymfpci *chip,
enum snd_ymfpci_voice_type type, int pair,
struct snd_ymfpci_voice **rvoice)
{
int result;
if (snd_BUG_ON(!rvoice))
return -EINVAL;
if (snd_BUG_ON(pair && type != YMFPCI_PCM))
return -EINVAL;
guard(spinlock_irqsave)(&chip->voice_lock);
for (;;) {
result = voice_alloc(chip, type, pair, rvoice);
if (result == 0 || type != YMFPCI_PCM)
break;
/* TODO: synth/midi voice deallocation */
break;
}
return result;
}
static int snd_ymfpci_voice_free(struct snd_ymfpci *chip, struct snd_ymfpci_voice *pvoice)
{
if (snd_BUG_ON(!pvoice))
return -EINVAL;
snd_ymfpci_hw_stop(chip);
guard(spinlock_irqsave)(&chip->voice_lock);
if (pvoice->number == chip->src441_used) {
chip->src441_used = -1;
pvoice->ypcm->use_441_slot = 0;
}
pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = 0;
pvoice->ypcm = NULL;
pvoice->interrupt = NULL;
return 0;
}
/*
* PCM part
*/
static void snd_ymfpci_pcm_interrupt(struct snd_ymfpci *chip, struct snd_ymfpci_voice *voice)
{
struct snd_ymfpci_pcm *ypcm;
u32 pos, delta;
ypcm = voice->ypcm;
if (!ypcm)
return;
if (ypcm->substream == NULL)
return;
guard(spinlock)(&chip->reg_lock);
if (ypcm->running) {
pos = le32_to_cpu(voice->bank[chip->active_bank].start);
if (pos < ypcm->last_pos)
delta = pos + (ypcm->buffer_size - ypcm->last_pos);
else
delta = pos - ypcm->last_pos;
ypcm->period_pos += delta;
ypcm->last_pos = pos;
if (ypcm->period_pos >= ypcm->period_size) {
/*
dev_dbg(chip->card->dev,
"done - active_bank = 0x%x, start = 0x%x\n",
chip->active_bank,
voice->bank[chip->active_bank].start);
*/
Annotation
- Immediate include surface: `linux/delay.h`, `linux/firmware.h`, `linux/init.h`, `linux/interrupt.h`, `linux/pci.h`, `linux/sched.h`, `linux/slab.h`, `linux/mutex.h`.
- Detected declarations: `function snd_ymfpci_writeb`, `function snd_ymfpci_readw`, `function snd_ymfpci_writew`, `function snd_ymfpci_readl`, `function snd_ymfpci_writel`, `function snd_ymfpci_codec_ready`, `function snd_ymfpci_codec_write`, `function snd_ymfpci_codec_read`, `function snd_ymfpci_calc_delta`, `function snd_ymfpci_calc_lpfK`.
- Atlas domain: Driver Families / sound/pci.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.