Lines Matching +full:command +full:- +full:sequencer

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) by Uros Bizjak <uros@kss-loka.si>
5 * Midi Sequencer interface routines for OPL2/OPL3/OPL4 FM
8 * alsa-tools/seq/sbiload/
17 MODULE_AUTHOR("Uros Bizjak <uros@kss-loka.si>");
27 if (!try_module_get(opl3->card->module)) in snd_opl3_synth_use_inc()
28 return -EFAULT; in snd_opl3_synth_use_inc()
35 module_put(opl3->card->module); in snd_opl3_synth_use_dec()
41 struct snd_hwdep *hwdep = opl3->hwdep; in snd_opl3_synth_setup()
43 mutex_lock(&hwdep->open_mutex); in snd_opl3_synth_setup()
44 if (hwdep->used) { in snd_opl3_synth_setup()
45 mutex_unlock(&hwdep->open_mutex); in snd_opl3_synth_setup()
46 return -EBUSY; in snd_opl3_synth_setup()
48 hwdep->used++; in snd_opl3_synth_setup()
49 mutex_unlock(&hwdep->open_mutex); in snd_opl3_synth_setup()
54 opl3->voices[idx].state = SNDRV_OPL3_ST_OFF; in snd_opl3_synth_setup()
55 opl3->voices[idx].time = 0; in snd_opl3_synth_setup()
56 opl3->voices[idx].keyon_reg = 0x00; in snd_opl3_synth_setup()
58 opl3->use_time = 0; in snd_opl3_synth_setup()
59 opl3->connection_reg = 0x00; in snd_opl3_synth_setup()
60 if (opl3->hardware >= OPL3_HW_OPL3) { in snd_opl3_synth_setup()
61 /* Clear 4-op connections */ in snd_opl3_synth_setup()
62 opl3->command(opl3, OPL3_RIGHT | OPL3_REG_CONNECTION_SELECT, in snd_opl3_synth_setup()
63 opl3->connection_reg); in snd_opl3_synth_setup()
64 opl3->max_voices = MAX_OPL3_VOICES; in snd_opl3_synth_setup()
75 spin_lock_irqsave(&opl3->sys_timer_lock, flags); in snd_opl3_synth_cleanup()
76 if (opl3->sys_timer_status) { in snd_opl3_synth_cleanup()
77 timer_delete(&opl3->tlist); in snd_opl3_synth_cleanup()
78 opl3->sys_timer_status = 0; in snd_opl3_synth_cleanup()
80 spin_unlock_irqrestore(&opl3->sys_timer_lock, flags); in snd_opl3_synth_cleanup()
83 hwdep = opl3->hwdep; in snd_opl3_synth_cleanup()
84 mutex_lock(&hwdep->open_mutex); in snd_opl3_synth_cleanup()
85 hwdep->used--; in snd_opl3_synth_cleanup()
86 mutex_unlock(&hwdep->open_mutex); in snd_opl3_synth_cleanup()
87 wake_up(&hwdep->open_wait); in snd_opl3_synth_cleanup()
101 opl3->voices[6].state = opl3->voices[7].state = in snd_opl3_synth_use()
102 opl3->voices[8].state = SNDRV_OPL3_ST_NOT_AVAIL; in snd_opl3_synth_use()
104 opl3->drum_reg = OPL3_PERCUSSION_ENABLE; in snd_opl3_synth_use()
105 opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION, opl3->drum_reg); in snd_opl3_synth_use()
107 opl3->drum_reg = 0x00; in snd_opl3_synth_use()
110 if (info->sender.client != SNDRV_SEQ_CLIENT_SYSTEM) { in snd_opl3_synth_use()
115 opl3->synth_mode = SNDRV_OPL3_MODE_SEQ; in snd_opl3_synth_use()
125 if (info->sender.client != SNDRV_SEQ_CLIENT_SYSTEM) in snd_opl3_synth_unuse()
148 snd_midi_process_event(&opl3_ops, ev, opl3->chset); in snd_opl3_synth_event_input()
152 /* ------------------------------ */
158 snd_midi_channel_free_set(opl3->chset); in snd_opl3_synth_free_port()
167 voices = (opl3->hardware < OPL3_HW_OPL3) ? in snd_opl3_synth_create_port()
169 opl3->chset = snd_midi_channel_alloc_set(16); in snd_opl3_synth_create_port()
170 if (opl3->chset == NULL) in snd_opl3_synth_create_port()
171 return -ENOMEM; in snd_opl3_synth_create_port()
172 opl3->chset->private_data = opl3; in snd_opl3_synth_create_port()
182 opl_ver = (opl3->hardware & OPL3_HW_MASK) >> 8; in snd_opl3_synth_create_port()
185 opl3->chset->client = opl3->seq_client; in snd_opl3_synth_create_port()
186 opl3->chset->port = snd_seq_event_port_attach(opl3->seq_client, &callbacks, in snd_opl3_synth_create_port()
196 if (opl3->chset->port < 0) { in snd_opl3_synth_create_port()
198 port = opl3->chset->port; in snd_opl3_synth_create_port()
199 snd_midi_channel_free_set(opl3->chset); in snd_opl3_synth_create_port()
205 /* ------------------------------ */
217 return -EINVAL; in snd_opl3_seq_probe()
219 spin_lock_init(&opl3->voice_lock); in snd_opl3_seq_probe()
221 opl3->seq_client = -1; in snd_opl3_seq_probe()
224 opl_ver = (opl3->hardware & OPL3_HW_MASK) >> 8; in snd_opl3_seq_probe()
226 client = opl3->seq_client = in snd_opl3_seq_probe()
227 snd_seq_create_kernel_client(opl3->card, opl3->seq_dev_num, in snd_opl3_seq_probe()
235 opl3->seq_client = -1; in snd_opl3_seq_probe()
240 timer_setup(&opl3->tlist, snd_opl3_timer_func, 0); in snd_opl3_seq_probe()
241 spin_lock_init(&opl3->sys_timer_lock); in snd_opl3_seq_probe()
242 opl3->sys_timer_status = 0; in snd_opl3_seq_probe()
257 return -EINVAL; in snd_opl3_seq_remove()
262 if (opl3->seq_client >= 0) { in snd_opl3_seq_remove()
263 snd_seq_delete_kernel_client(opl3->seq_client); in snd_opl3_seq_remove()
264 opl3->seq_client = -1; in snd_opl3_seq_remove()