Lines Matching defs:opl3
15 #define opl3_dbg(opl3, fmt, ...) \
16 dev_dbg(((struct snd_opl3 *)(opl3))->card->dev, fmt, ##__VA_ARGS__)
18 #define opl3_dbg(opl3, fmt, ...) do {} while (0)
117 static void debug_alloc(struct snd_opl3 *opl3, char *s, int voice)
123 for (i = 0; i < opl3->max_voices; i++)
124 buf[i] = str[opl3->voices[i].state + 1];
126 dev_dbg(opl3->card->dev, "time %.5i: %s [%.2i]: %s\n",
127 opl3->use_time, s, voice, buf);
134 static int opl3_get_voice(struct snd_opl3 *opl3, int instr_4op,
165 for (i = 0; i < opl3->max_voices; i++) {
166 vp = &opl3->voices[i];
189 vp2 = &opl3->voices[i + 3];
216 dev_dbg(opl3->card->dev,
236 struct snd_opl3 *opl3 = timer_container_of(opl3, t, tlist);
240 scoped_guard(spinlock_irqsave, &opl3->voice_lock) {
241 for (i = 0; i < opl3->max_voices; i++) {
242 struct snd_opl3_voice *vp = &opl3->voices[i];
245 snd_opl3_note_off_unsafe(opl3, vp->note, 0,
253 guard(spinlock_irqsave)(&opl3->sys_timer_lock);
255 mod_timer(&opl3->tlist, jiffies + 1); /* invoke again */
257 opl3->sys_timer_status = 0;
263 static void snd_opl3_start_timer(struct snd_opl3 *opl3)
265 guard(spinlock_irqsave)(&opl3->sys_timer_lock);
266 if (! opl3->sys_timer_status) {
267 mod_timer(&opl3->tlist, jiffies + 1);
268 opl3->sys_timer_status = 1;
284 struct snd_opl3 *opl3;
309 opl3 = p;
311 opl3_dbg(opl3, "Note on, ch %i, inst %i, note %i, vel %i\n",
316 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
335 guard(spinlock_irqsave)(&opl3->voice_lock);
338 snd_opl3_drum_switch(opl3, note, vel, 1, chan);
343 patch = snd_opl3_find_patch(opl3, prg, bank, 0);
353 if (opl3->hardware >= OPL3_HW_OPL3) {
361 opl3_dbg(opl3, " --> OPL%i instrument: %s\n",
365 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
366 voice = opl3_get_voice(opl3, instr_4op, chan);
388 vp = &opl3->voices[voice];
392 opl3->command(opl3, opl3_reg, reg_val);
395 vp2 = &opl3->voices[voice + 3];
400 opl3->command(opl3, opl3_reg, reg_val);
406 if ((opl3->connection_reg ^ connect_mask) & connect_mask) {
407 opl3->connection_reg |= connect_mask;
410 opl3->command(opl3, opl3_reg, opl3->connection_reg);
413 if ((opl3->connection_reg ^ ~connect_mask) & connect_mask) {
414 opl3->connection_reg &= ~connect_mask;
417 opl3->command(opl3, opl3_reg, opl3->connection_reg);
421 opl3_dbg(opl3, " --> setting OPL3 connection: 0x%x\n",
422 opl3->connection_reg);
425 * between FM operators (see include/opl3.h)
454 opl3_dbg(opl3, " --> programming operator %i\n", i);
460 opl3->command(opl3, opl3_reg, reg_val);
465 opl3->command(opl3, opl3_reg, reg_val);
470 opl3->command(opl3, opl3_reg, reg_val);
475 opl3->command(opl3, opl3_reg, reg_val);
480 opl3->command(opl3, opl3_reg, reg_val);
492 opl3->command(opl3, opl3_reg, reg_val);
505 opl3->command(opl3, opl3_reg, reg_val);
525 opl3->command(opl3, opl3_reg, fnum);
527 opl3->voices[voice].keyon_reg = blocknum;
532 opl3_dbg(opl3, " --> trigger voice %i\n", voice);
535 opl3->command(opl3, opl3_reg, blocknum);
539 opl3->voices[voice].note_off = jiffies +
541 snd_opl3_start_timer(opl3);
542 opl3->voices[voice].note_off_check = 1;
544 opl3->voices[voice].note_off_check = 0;
550 vp->time = opl3->use_time++;
557 vp2 = &opl3->voices[voice + 3];
558 vp2->time = opl3->use_time++;
565 vp2 = &opl3->voices[voice + 3];
566 vp2->time = opl3->use_time++;
573 debug_alloc(opl3, "note on ", voice);
586 opl3_dbg(opl3, " *** allocating extra program\n");
591 static void snd_opl3_kill_voice(struct snd_opl3 *opl3, int voice)
602 vp = &opl3->voices[voice];
614 opl3_dbg(opl3, " --> kill voice %i\n", voice);
617 opl3->command(opl3, opl3_reg, vp->keyon_reg);
620 vp->time = opl3->use_time++;
623 vp2 = &opl3->voices[voice + 3];
625 vp2->time = opl3->use_time++;
630 debug_alloc(opl3, "note off", voice);
641 struct snd_opl3 *opl3;
646 opl3 = p;
648 opl3_dbg(opl3, "Note off, ch %i, inst %i, note %i\n",
651 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
653 snd_opl3_drum_switch(opl3, note, vel, 0, chan);
658 for (voice = 0; voice < opl3->max_voices; voice++) {
659 vp = &opl3->voices[voice];
661 snd_opl3_kill_voice(opl3, voice);
668 snd_opl3_kill_voice(opl3, voice);
676 struct snd_opl3 *opl3 = p;
678 guard(spinlock_irqsave)(&opl3->voice_lock);
700 static void snd_opl3_update_pitch(struct snd_opl3 *opl3, int voice)
713 vp = &opl3->voices[voice];
731 opl3->command(opl3, opl3_reg, fnum);
740 opl3->command(opl3, opl3_reg, blocknum);
742 vp->time = opl3->use_time++;
748 static void snd_opl3_pitch_ctrl(struct snd_opl3 *opl3, struct snd_midi_channel *chan)
753 guard(spinlock_irqsave)(&opl3->voice_lock);
755 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
756 for (voice = 0; voice < opl3->max_voices; voice++) {
757 vp = &opl3->voices[voice];
759 snd_opl3_update_pitch(opl3, voice);
766 snd_opl3_update_pitch(opl3, voice);
777 struct snd_opl3 *opl3;
779 opl3 = p;
780 opl3_dbg(opl3, "Controller, TYPE = %i, ch#: %i, inst#: %i\n",
786 opl3->drum_reg |= OPL3_VIBRATO_DEPTH;
788 opl3->drum_reg &= ~OPL3_VIBRATO_DEPTH;
789 opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION,
790 opl3->drum_reg);
794 opl3->drum_reg |= OPL3_TREMOLO_DEPTH;
796 opl3->drum_reg &= ~OPL3_TREMOLO_DEPTH;
797 opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION,
798 opl3->drum_reg);
801 snd_opl3_pitch_ctrl(opl3, chan);