sound/drivers/opl3/opl3_seq.c
Source file repositories/reference/linux-study-clean/sound/drivers/opl3/opl3_seq.c
File Facts
- System
- Linux kernel
- Corpus path
sound/drivers/opl3/opl3_seq.c- Extension
.c- Size
- 6581 bytes
- Lines
- 274
- Domain
- Driver Families
- Bucket
- sound/drivers
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
opl3_voice.hlinux/init.hlinux/moduleparam.hlinux/module.hsound/initval.h
Detected Declarations
function snd_opl3_synth_use_incfunction snd_opl3_synth_use_decfunction snd_opl3_synth_setupfunction scoped_guardfunction snd_opl3_synth_cleanupfunction snd_opl3_synth_usefunction snd_opl3_synth_unusefunction snd_opl3_synth_event_inputfunction snd_opl3_synth_free_portfunction snd_opl3_synth_create_portfunction snd_opl3_seq_probefunction snd_opl3_seq_remove
Annotated Snippet
if (opl3->sys_timer_status) {
timer_delete(&opl3->tlist);
opl3->sys_timer_status = 0;
}
}
snd_opl3_reset(opl3);
hwdep = opl3->hwdep;
scoped_guard(mutex, &hwdep->open_mutex) {
hwdep->used--;
}
wake_up(&hwdep->open_wait);
}
static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribe * info)
{
struct snd_opl3 *opl3 = private_data;
int err;
err = snd_opl3_synth_setup(opl3);
if (err < 0)
return err;
if (use_internal_drums) {
/* Percussion mode */
opl3->voices[6].state = opl3->voices[7].state =
opl3->voices[8].state = SNDRV_OPL3_ST_NOT_AVAIL;
snd_opl3_load_drums(opl3);
opl3->drum_reg = OPL3_PERCUSSION_ENABLE;
opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION, opl3->drum_reg);
} else {
opl3->drum_reg = 0x00;
}
if (info->sender.client != SNDRV_SEQ_CLIENT_SYSTEM) {
err = snd_opl3_synth_use_inc(opl3);
if (err < 0)
return err;
}
opl3->synth_mode = SNDRV_OPL3_MODE_SEQ;
return 0;
}
static int snd_opl3_synth_unuse(void *private_data, struct snd_seq_port_subscribe * info)
{
struct snd_opl3 *opl3 = private_data;
snd_opl3_synth_cleanup(opl3);
if (info->sender.client != SNDRV_SEQ_CLIENT_SYSTEM)
snd_opl3_synth_use_dec(opl3);
return 0;
}
/*
* MIDI emulation operators
*/
const struct snd_midi_op opl3_ops = {
.note_on = snd_opl3_note_on,
.note_off = snd_opl3_note_off,
.key_press = snd_opl3_key_press,
.note_terminate = snd_opl3_terminate_note,
.control = snd_opl3_control,
.nrpn = snd_opl3_nrpn,
.sysex = snd_opl3_sysex,
};
static int snd_opl3_synth_event_input(struct snd_seq_event * ev, int direct,
void *private_data, int atomic, int hop)
{
struct snd_opl3 *opl3 = private_data;
snd_midi_process_event(&opl3_ops, ev, opl3->chset);
return 0;
}
/* ------------------------------ */
static void snd_opl3_synth_free_port(void *private_data)
{
struct snd_opl3 *opl3 = private_data;
snd_midi_channel_free_set(opl3->chset);
}
static int snd_opl3_synth_create_port(struct snd_opl3 * opl3)
{
struct snd_seq_port_callback callbacks;
char name[32];
int voices, opl_ver;
Annotation
- Immediate include surface: `opl3_voice.h`, `linux/init.h`, `linux/moduleparam.h`, `linux/module.h`, `sound/initval.h`.
- Detected declarations: `function snd_opl3_synth_use_inc`, `function snd_opl3_synth_use_dec`, `function snd_opl3_synth_setup`, `function scoped_guard`, `function snd_opl3_synth_cleanup`, `function snd_opl3_synth_use`, `function snd_opl3_synth_unuse`, `function snd_opl3_synth_event_input`, `function snd_opl3_synth_free_port`, `function snd_opl3_synth_create_port`.
- Atlas domain: Driver Families / sound/drivers.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.