sound/pci/emu10k1/p16v.c
Source file repositories/reference/linux-study-clean/sound/pci/emu10k1/p16v.c
File Facts
- System
- Linux kernel
- Corpus path
sound/pci/emu10k1/p16v.c- Extension
.c- Size
- 26017 bytes
- Lines
- 827
- 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.
- 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/init.hlinux/interrupt.hlinux/pci.hlinux/slab.hlinux/vmalloc.hlinux/moduleparam.hsound/core.hsound/initval.hsound/pcm.hsound/ac97_codec.hsound/info.hsound/tlv.hsound/emu10k1.hp16v.h
Detected Declarations
function snd_p16v_pcm_open_playback_channelfunction snd_p16v_pcm_open_capture_channelfunction snd_p16v_pcm_close_playbackfunction snd_p16v_pcm_close_capturefunction snd_p16v_pcm_open_playback_frontfunction snd_p16v_pcm_open_capturefunction snd_p16v_pcm_ioctl_playbackfunction snd_p16v_pcm_prepare_playbackfunction snd_p16v_pcm_prepare_capturefunction snd_p16v_intr_enablefunction snd_p16v_intr_disablefunction snd_p16v_interruptfunction snd_p16v_pcm_trigger_playbackfunction snd_pcm_group_for_each_entryfunction snd_p16v_pcm_trigger_capturefunction snd_p16v_pcm_pointer_playbackfunction snd_p16v_pcm_pointer_capturefunction snd_p16v_pcmfunction snd_p16v_volume_infofunction snd_p16v_volume_getfunction snd_p16v_volume_putfunction snd_p16v_capture_source_infofunction snd_p16v_capture_source_getfunction snd_p16v_capture_source_putfunction snd_p16v_capture_channel_infofunction snd_p16v_capture_channel_getfunction snd_p16v_capture_channel_putfunction snd_p16v_mixerfunction snd_p16v_alloc_pm_bufferfunction snd_p16v_free_pm_bufferfunction snd_p16v_suspendfunction snd_p16v_resume
Annotated Snippet
switch (runtime->rate) {
case 44100:
snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel,
tmp | A_SPDIF_44100 | A_EHC_SRC48_44);
break;
case 96000:
snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel,
tmp | A_SPDIF_96000 | A_EHC_SRC48_96);
break;
case 192000:
snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel,
tmp | A_SPDIF_192000 | A_EHC_SRC48_192);
break;
case 48000:
default:
snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel,
tmp | A_SPDIF_48000 | A_EHC_SRC48_BYPASS);
break;
}
/* FIXME: Check emu->buffer.size before actually writing to it. */
for(i = 0; i < runtime->periods; i++) {
table_base[i*2]=runtime->dma_addr+(i*period_size_bytes);
table_base[(i*2)+1]=period_size_bytes<<16;
}
snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_ADDR, channel, emu->p16v_buffer->addr+(8*16*channel));
snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_SIZE, channel, (runtime->periods - 1) << 19);
snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_PTR, channel, 0);
snd_emu10k1_ptr20_write(emu, PLAYBACK_DMA_ADDR, channel, runtime->dma_addr);
//snd_emu10k1_ptr20_write(emu, PLAYBACK_PERIOD_SIZE, channel, frames_to_bytes(runtime, runtime->period_size)<<16); // buffer size in bytes
snd_emu10k1_ptr20_write(emu, PLAYBACK_PERIOD_SIZE, channel, 0); // buffer size in bytes
snd_emu10k1_ptr20_write(emu, PLAYBACK_POINTER, channel, 0);
snd_emu10k1_ptr20_write(emu, PLAYBACK_FIFO_END_ADDRESS, channel, 0);
snd_emu10k1_ptr20_write(emu, PLAYBACK_FIFO_POINTER, channel, 0);
return 0;
}
/* prepare capture callback */
static int snd_p16v_pcm_prepare_capture(struct snd_pcm_substream *substream)
{
struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
int channel = substream->pcm->device - emu->p16v_device_offset;
/*
dev_dbg(emu->card->dev, "prepare capture:channel_number=%d, rate=%d, "
"format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, "
"frames_to_bytes=%d\n",
channel, runtime->rate, runtime->format, runtime->channels,
runtime->buffer_size, runtime->period_size,
frames_to_bytes(runtime, 1));
*/
switch (runtime->rate) {
case 44100:
snd_emu10k1_ptr_write(emu, A_I2S_CAPTURE_RATE, channel, A_I2S_CAPTURE_44100);
break;
case 96000:
snd_emu10k1_ptr_write(emu, A_I2S_CAPTURE_RATE, channel, A_I2S_CAPTURE_96000);
break;
case 192000:
snd_emu10k1_ptr_write(emu, A_I2S_CAPTURE_RATE, channel, A_I2S_CAPTURE_192000);
break;
case 48000:
default:
snd_emu10k1_ptr_write(emu, A_I2S_CAPTURE_RATE, channel, A_I2S_CAPTURE_48000);
break;
}
/* FIXME: Check emu->buffer.size before actually writing to it. */
snd_emu10k1_ptr20_write(emu, CAPTURE_FIFO_POINTER, channel, 0);
snd_emu10k1_ptr20_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr);
snd_emu10k1_ptr20_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_size) << 16); // buffer size in bytes
snd_emu10k1_ptr20_write(emu, CAPTURE_POINTER, channel, 0);
//snd_emu10k1_ptr20_write(emu, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC or Line in */
//snd_emu10k1_ptr20_write(emu, EXTENDED_INT_MASK, 0, snd_emu10k1_ptr20_read(emu, EXTENDED_INT_MASK, 0) | (0x110000<<channel));
return 0;
}
static void snd_p16v_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb)
{
unsigned int enable;
guard(spinlock_irqsave)(&emu->emu_lock);
enable = inl(emu->port + INTE2) | intrenb;
outl(enable, emu->port + INTE2);
}
static void snd_p16v_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb)
{
Annotation
- Immediate include surface: `linux/delay.h`, `linux/init.h`, `linux/interrupt.h`, `linux/pci.h`, `linux/slab.h`, `linux/vmalloc.h`, `linux/moduleparam.h`, `sound/core.h`.
- Detected declarations: `function snd_p16v_pcm_open_playback_channel`, `function snd_p16v_pcm_open_capture_channel`, `function snd_p16v_pcm_close_playback`, `function snd_p16v_pcm_close_capture`, `function snd_p16v_pcm_open_playback_front`, `function snd_p16v_pcm_open_capture`, `function snd_p16v_pcm_ioctl_playback`, `function snd_p16v_pcm_prepare_playback`, `function snd_p16v_pcm_prepare_capture`, `function snd_p16v_intr_enable`.
- Atlas domain: Driver Families / sound/pci.
- Implementation status: source implementation candidate.
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.