sound/drivers/mpu401/mpu401_uart.c
Source file repositories/reference/linux-study-clean/sound/drivers/mpu401/mpu401_uart.c
File Facts
- System
- Linux kernel
- Corpus path
sound/drivers/mpu401/mpu401_uart.c- Extension
.c- Size
- 15398 bytes
- Lines
- 596
- Domain
- Driver Families
- Bucket
- sound/drivers
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/io.hlinux/delay.hlinux/init.hlinux/slab.hlinux/ioport.hlinux/module.hlinux/interrupt.hlinux/errno.hsound/core.hsound/mpu401.h
Detected Declarations
function mpu401_write_portfunction mpu401_read_portfunction mpu401_write_mmiofunction mpu401_read_mmiofunction snd_mpu401_uart_clear_rxfunction uart_interrupt_txfunction _snd_mpu401_uart_interruptfunction snd_mpu401_uart_interruptfunction snd_mpu401_uart_interrupt_txfunction snd_mpu401_uart_timerfunction scoped_guardfunction snd_mpu401_uart_add_timerfunction snd_mpu401_uart_remove_timerfunction snd_mpu401_uart_cmdfunction snd_mpu401_do_resetfunction snd_mpu401_uart_input_openfunction snd_mpu401_uart_output_openfunction snd_mpu401_uart_input_closefunction snd_mpu401_uart_output_closefunction snd_mpu401_uart_input_triggerfunction snd_mpu401_uart_input_readfunction snd_mpu401_uart_output_writefunction snd_mpu401_uart_output_triggerfunction snd_mpu401_uart_freefunction snd_mpu401_uart_newexport snd_mpu401_uart_interruptexport snd_mpu401_uart_interrupt_txexport snd_mpu401_uart_new
Annotated Snippet
test_bit(MPU401_MODE_BIT_OUTPUT_TRIGGER, &mpu->mode)) {
guard(spinlock_irqsave)(&mpu->output_lock);
snd_mpu401_uart_output_write(mpu);
}
}
static void _snd_mpu401_uart_interrupt(struct snd_mpu401 *mpu)
{
if (mpu->info_flags & MPU401_INFO_INPUT) {
guard(spinlock_irqsave)(&mpu->input_lock);
if (test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode))
snd_mpu401_uart_input_read(mpu);
else
snd_mpu401_uart_clear_rx(mpu);
}
if (! (mpu->info_flags & MPU401_INFO_TX_IRQ))
/* ok. for better Tx performance try do some output
when input is done */
uart_interrupt_tx(mpu);
}
/**
* snd_mpu401_uart_interrupt - generic MPU401-UART interrupt handler
* @irq: the irq number
* @dev_id: mpu401 instance
*
* Processes the interrupt for MPU401-UART i/o.
*
* Return: %IRQ_HANDLED if the interrupt was handled. %IRQ_NONE otherwise.
*/
irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id)
{
struct snd_mpu401 *mpu = dev_id;
if (!mpu)
return IRQ_NONE;
_snd_mpu401_uart_interrupt(mpu);
return IRQ_HANDLED;
}
EXPORT_SYMBOL(snd_mpu401_uart_interrupt);
/**
* snd_mpu401_uart_interrupt_tx - generic MPU401-UART transmit irq handler
* @irq: the irq number
* @dev_id: mpu401 instance
*
* Processes the interrupt for MPU401-UART output.
*
* Return: %IRQ_HANDLED if the interrupt was handled. %IRQ_NONE otherwise.
*/
irqreturn_t snd_mpu401_uart_interrupt_tx(int irq, void *dev_id)
{
struct snd_mpu401 *mpu = dev_id;
if (!mpu)
return IRQ_NONE;
uart_interrupt_tx(mpu);
return IRQ_HANDLED;
}
EXPORT_SYMBOL(snd_mpu401_uart_interrupt_tx);
/*
* timer callback
* reprogram the timer and call the interrupt job
*/
static void snd_mpu401_uart_timer(struct timer_list *t)
{
struct snd_mpu401 *mpu = timer_container_of(mpu, t, timer);
scoped_guard(spinlock_irqsave, &mpu->timer_lock) {
/*mpu->mode |= MPU401_MODE_TIMER;*/
mod_timer(&mpu->timer, 1 + jiffies);
}
if (mpu->rmidi)
_snd_mpu401_uart_interrupt(mpu);
}
/*
* initialize the timer callback if not programmed yet
*/
static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu, int input)
{
guard(spinlock_irqsave)(&mpu->timer_lock);
if (mpu->timer_invoked == 0) {
timer_setup(&mpu->timer, snd_mpu401_uart_timer, 0);
mod_timer(&mpu->timer, 1 + jiffies);
}
mpu->timer_invoked |= input ? MPU401_MODE_INPUT_TIMER :
Annotation
- Immediate include surface: `linux/io.h`, `linux/delay.h`, `linux/init.h`, `linux/slab.h`, `linux/ioport.h`, `linux/module.h`, `linux/interrupt.h`, `linux/errno.h`.
- Detected declarations: `function mpu401_write_port`, `function mpu401_read_port`, `function mpu401_write_mmio`, `function mpu401_read_mmio`, `function snd_mpu401_uart_clear_rx`, `function uart_interrupt_tx`, `function _snd_mpu401_uart_interrupt`, `function snd_mpu401_uart_interrupt`, `function snd_mpu401_uart_interrupt_tx`, `function snd_mpu401_uart_timer`.
- Atlas domain: Driver Families / sound/drivers.
- Implementation status: integration 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.