sound/pci/emu10k1/emufx.c
Source file repositories/reference/linux-study-clean/sound/pci/emu10k1/emufx.c
File Facts
- System
- Linux kernel
- Corpus path
sound/pci/emu10k1/emufx.c- Extension
.c- Size
- 95510 bytes
- Lines
- 2723
- 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.
- 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.
- 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/pci.hlinux/capability.hlinux/delay.hlinux/slab.hlinux/string.hlinux/vmalloc.hlinux/init.hlinux/mutex.hlinux/moduleparam.hlinux/nospec.hsound/core.hsound/tlv.hsound/emu10k1.h
Detected Declarations
function snd_emu10k1_gpr_ctl_infofunction snd_emu10k1_gpr_ctl_getfunction snd_emu10k1_gpr_ctl_putfunction snd_emu10k1_fx8010_interruptfunction snd_emu10k1_fx8010_register_irq_handlerfunction snd_emu10k1_fx8010_unregister_irq_handlerfunction snd_emu10k1_write_opfunction snd_emu10k1_audigy_write_opfunction snd_emu10k1_efx_writefunction snd_emu10k1_efx_readfunction snd_emu10k1_gpr_pokefunction snd_emu10k1_gpr_peekfunction snd_emu10k1_tram_pokefunction snd_emu10k1_tram_peekfunction snd_emu10k1_code_pokefunction snd_emu10k1_code_peekfunction snd_emu10k1_look_for_ctlfunction list_for_each_entryfunction copy_gctlfunction copy_gctl_to_userfunction copy_ctl_elem_idfunction snd_emu10k1_verify_controlsfunction snd_emu10k1_ctl_private_freefunction snd_emu10k1_add_controlsfunction snd_emu10k1_del_controlsfunction snd_emu10k1_list_controlsfunction list_for_each_entryfunction snd_emu10k1_icode_pokefunction snd_emu10k1_icode_peekfunction snd_emu10k1_ipcm_pokefunction snd_emu10k1_ipcm_peekfunction snd_emu10k1_init_mono_control2function snd_emu10k1_init_stereo_control2function snd_emu10k1_init_mono_onoff_controlfunction snd_emu10k1_init_stereo_onoff_controlfunction snd_emu10k1_audigy_dsp_convert_32_to_2x16function _snd_emu10k1_audigy_init_efxfunction _volumefunction _volume_addfunction _SWITCH_NEGfunction snd_emu10k1_init_efxfunction snd_emu10k1_free_efxfunction snd_emu10k1_fx8010_tone_control_activatefunction snd_emu10k1_fx8010_tone_control_deactivatefunction snd_emu10k1_fx8010_tram_setupfunction scoped_guardfunction snd_emu10k1_fx8010_openfunction copy_string
Annotated Snippet
switch (ctl->translation) {
case EMU10K1_GPR_TRANSLATION_NONE:
snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, val);
break;
case EMU10K1_GPR_TRANSLATION_NEGATE:
snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, ~val);
break;
case EMU10K1_GPR_TRANSLATION_TABLE100:
snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, db_table[val]);
break;
case EMU10K1_GPR_TRANSLATION_NEG_TABLE100:
snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0,
val == 100 ? 0x80000000 : -(int)db_table[val]);
break;
case EMU10K1_GPR_TRANSLATION_BASS:
if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) {
change = -EIO;
goto __error;
}
for (j = 0; j < 5; j++)
snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, bass_table[val][j]);
break;
case EMU10K1_GPR_TRANSLATION_TREBLE:
if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) {
change = -EIO;
goto __error;
}
for (j = 0; j < 5; j++)
snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, treble_table[val][j]);
break;
case EMU10K1_GPR_TRANSLATION_ONOFF:
snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, onoff_table[val]);
break;
}
}
__error:
return change;
}
/*
* Interrupt handler
*/
static void snd_emu10k1_fx8010_interrupt(struct snd_emu10k1 *emu)
{
struct snd_emu10k1_fx8010_irq *irq, *nirq;
irq = emu->fx8010.irq_handlers;
while (irq) {
nirq = irq->next; /* irq ptr can be removed from list */
if (snd_emu10k1_ptr_read(emu, emu->gpr_base + irq->gpr_running, 0) & 0xffff0000) {
if (irq->handler)
irq->handler(emu, irq->private_data);
snd_emu10k1_ptr_write(emu, emu->gpr_base + irq->gpr_running, 0, 1);
}
irq = nirq;
}
}
int snd_emu10k1_fx8010_register_irq_handler(struct snd_emu10k1 *emu,
snd_fx8010_irq_handler_t *handler,
unsigned char gpr_running,
void *private_data,
struct snd_emu10k1_fx8010_irq *irq)
{
irq->handler = handler;
irq->gpr_running = gpr_running;
irq->private_data = private_data;
irq->next = NULL;
guard(spinlock_irqsave)(&emu->fx8010.irq_lock);
if (emu->fx8010.irq_handlers == NULL) {
emu->fx8010.irq_handlers = irq;
emu->dsp_interrupt = snd_emu10k1_fx8010_interrupt;
snd_emu10k1_intr_enable(emu, INTE_FXDSPENABLE);
} else {
irq->next = emu->fx8010.irq_handlers;
emu->fx8010.irq_handlers = irq;
}
return 0;
}
int snd_emu10k1_fx8010_unregister_irq_handler(struct snd_emu10k1 *emu,
struct snd_emu10k1_fx8010_irq *irq)
{
struct snd_emu10k1_fx8010_irq *tmp;
guard(spinlock_irqsave)(&emu->fx8010.irq_lock);
tmp = emu->fx8010.irq_handlers;
if (tmp == irq) {
emu->fx8010.irq_handlers = tmp->next;
Annotation
- Immediate include surface: `linux/pci.h`, `linux/capability.h`, `linux/delay.h`, `linux/slab.h`, `linux/string.h`, `linux/vmalloc.h`, `linux/init.h`, `linux/mutex.h`.
- Detected declarations: `function snd_emu10k1_gpr_ctl_info`, `function snd_emu10k1_gpr_ctl_get`, `function snd_emu10k1_gpr_ctl_put`, `function snd_emu10k1_fx8010_interrupt`, `function snd_emu10k1_fx8010_register_irq_handler`, `function snd_emu10k1_fx8010_unregister_irq_handler`, `function snd_emu10k1_write_op`, `function snd_emu10k1_audigy_write_op`, `function snd_emu10k1_efx_write`, `function snd_emu10k1_efx_read`.
- Atlas domain: Driver Families / sound/pci.
- 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.
- 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.