sound/isa/sb/sb8_midi.c
Source file repositories/reference/linux-study-clean/sound/isa/sb/sb8_midi.c
File Facts
- System
- Linux kernel
- Corpus path
sound/isa/sb/sb8_midi.c- Extension
.c- Size
- 6708 bytes
- Lines
- 244
- Domain
- Driver Families
- Bucket
- sound/isa
- 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 IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/io.hlinux/string.hlinux/time.hsound/core.hsound/sb.h
Detected Declarations
function Copyrightfunction snd_sb8dsp_midi_input_openfunction snd_sb8dsp_midi_output_openfunction snd_sb8dsp_midi_input_closefunction snd_sb8dsp_midi_output_closefunction snd_sb8dsp_midi_input_triggerfunction snd_sb8dsp_midi_output_writefunction snd_sb8dsp_midi_output_timerfunction scoped_guardfunction snd_sb8dsp_midi_output_triggerfunction snd_sb8dsp_midi
Annotated Snippet
if (inb(SBP(chip, DATA_AVAIL)) & 0x80) {
byte = inb(SBP(chip, READ));
if (chip->open & SB_OPEN_MIDI_INPUT_TRIGGER) {
snd_rawmidi_receive(chip->midi_substream_input, &byte, 1);
}
}
}
return IRQ_HANDLED;
}
static int snd_sb8dsp_midi_input_open(struct snd_rawmidi_substream *substream)
{
struct snd_sb *chip;
unsigned int valid_open_flags;
chip = substream->rmidi->private_data;
valid_open_flags = chip->hardware >= SB_HW_20
? SB_OPEN_MIDI_OUTPUT | SB_OPEN_MIDI_OUTPUT_TRIGGER : 0;
scoped_guard(spinlock_irqsave, &chip->open_lock) {
if (chip->open & ~valid_open_flags)
return -EAGAIN;
chip->open |= SB_OPEN_MIDI_INPUT;
chip->midi_substream_input = substream;
if (chip->open & SB_OPEN_MIDI_OUTPUT)
return 0;
}
snd_sbdsp_reset(chip); /* reset DSP */
if (chip->hardware >= SB_HW_20)
snd_sbdsp_command(chip, SB_DSP_MIDI_UART_IRQ);
return 0;
}
static int snd_sb8dsp_midi_output_open(struct snd_rawmidi_substream *substream)
{
struct snd_sb *chip;
unsigned int valid_open_flags;
chip = substream->rmidi->private_data;
valid_open_flags = chip->hardware >= SB_HW_20
? SB_OPEN_MIDI_INPUT | SB_OPEN_MIDI_INPUT_TRIGGER : 0;
scoped_guard(spinlock_irqsave, &chip->open_lock) {
if (chip->open & ~valid_open_flags)
return -EAGAIN;
chip->open |= SB_OPEN_MIDI_OUTPUT;
chip->midi_substream_output = substream;
if (chip->open & SB_OPEN_MIDI_INPUT)
return 0;
}
snd_sbdsp_reset(chip); /* reset DSP */
if (chip->hardware >= SB_HW_20)
snd_sbdsp_command(chip, SB_DSP_MIDI_UART_IRQ);
return 0;
}
static int snd_sb8dsp_midi_input_close(struct snd_rawmidi_substream *substream)
{
struct snd_sb *chip;
chip = substream->rmidi->private_data;
scoped_guard(spinlock_irqsave, &chip->open_lock) {
chip->open &= ~(SB_OPEN_MIDI_INPUT | SB_OPEN_MIDI_INPUT_TRIGGER);
chip->midi_substream_input = NULL;
if (chip->open & SB_OPEN_MIDI_OUTPUT)
return 0;
}
snd_sbdsp_reset(chip); /* reset DSP */
return 0;
}
static int snd_sb8dsp_midi_output_close(struct snd_rawmidi_substream *substream)
{
struct snd_sb *chip;
chip = substream->rmidi->private_data;
timer_delete_sync(&chip->midi_timer);
scoped_guard(spinlock_irqsave, &chip->open_lock) {
chip->open &= ~(SB_OPEN_MIDI_OUTPUT | SB_OPEN_MIDI_OUTPUT_TRIGGER);
chip->midi_substream_output = NULL;
if (chip->open & SB_OPEN_MIDI_INPUT)
return 0;
}
snd_sbdsp_reset(chip); /* reset DSP */
return 0;
}
static void snd_sb8dsp_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
{
struct snd_sb *chip;
chip = substream->rmidi->private_data;
Annotation
- Immediate include surface: `linux/io.h`, `linux/string.h`, `linux/time.h`, `sound/core.h`, `sound/sb.h`.
- Detected declarations: `function Copyright`, `function snd_sb8dsp_midi_input_open`, `function snd_sb8dsp_midi_output_open`, `function snd_sb8dsp_midi_input_close`, `function snd_sb8dsp_midi_output_close`, `function snd_sb8dsp_midi_input_trigger`, `function snd_sb8dsp_midi_output_write`, `function snd_sb8dsp_midi_output_timer`, `function scoped_guard`, `function snd_sb8dsp_midi_output_trigger`.
- Atlas domain: Driver Families / sound/isa.
- Implementation status: source implementation candidate.
- 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.