Lines Matching +full:op +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) by Uros Bizjak <uros@kss-loka.si>
20 * There is 18 possible 2 OP voices
22 * The first OP is the modulator and 2nd is the carrier.
25 * with another voice to a 4 OP voice. For example voice 0
27 * used as operators 3 and 4 of the new 4 OP voice.
28 * In this case the 2 OP voice number 0 is the 'first half' and
41 /* ------------------------ */
51 { 0x11, 0x14, 0x00, 0x00 }, /* if the percussive mode */
63 static int snd_opl3_set_mode(struct snd_opl3 * opl3, int mode);
66 /* ------------------------------ */
82 struct snd_opl3 *opl3 = hw->private_data; in snd_opl3_ioctl()
86 return -EINVAL; in snd_opl3_ioctl()
96 info.fm_mode = opl3->fm_mode; in snd_opl3_ioctl()
97 info.rhythm = opl3->rhythm; in snd_opl3_ioctl()
99 return -EFAULT; in snd_opl3_ioctl()
117 return -EFAULT; in snd_opl3_ioctl()
128 return -EFAULT; in snd_opl3_ioctl()
139 return -EFAULT; in snd_opl3_ioctl()
166 return -ENOTTY; in snd_opl3_ioctl()
174 struct snd_opl3 *opl3 = hw->private_data; in snd_opl3_release()
182 * write the device - load patches
187 struct snd_opl3 *opl3 = hw->private_data; in snd_opl3_write()
195 return -EFAULT; in snd_opl3_write()
209 count -= sizeof(inst); in snd_opl3_write()
252 return -ENOMEM; in snd_opl3_load_patch()
254 patch->type = type; in snd_opl3_load_patch()
257 patch->inst.op[i].am_vib = data[AM_VIB + i]; in snd_opl3_load_patch()
258 patch->inst.op[i].ksl_level = data[KSL_LEVEL + i]; in snd_opl3_load_patch()
259 patch->inst.op[i].attack_decay = data[ATTACK_DECAY + i]; in snd_opl3_load_patch()
260 patch->inst.op[i].sustain_release = data[SUSTAIN_RELEASE + i]; in snd_opl3_load_patch()
261 patch->inst.op[i].wave_select = data[WAVE_SELECT + i]; in snd_opl3_load_patch()
263 patch->inst.feedback_connection[0] = data[CONNECTION]; in snd_opl3_load_patch()
267 patch->inst.op[i+2].am_vib = in snd_opl3_load_patch()
269 patch->inst.op[i+2].ksl_level = in snd_opl3_load_patch()
271 patch->inst.op[i+2].attack_decay = in snd_opl3_load_patch()
273 patch->inst.op[i+2].sustain_release = in snd_opl3_load_patch()
275 patch->inst.op[i+2].wave_select = in snd_opl3_load_patch()
278 patch->inst.feedback_connection[1] = in snd_opl3_load_patch()
283 patch->inst.echo_delay = ext[0]; in snd_opl3_load_patch()
284 patch->inst.echo_atten = ext[1]; in snd_opl3_load_patch()
285 patch->inst.chorus_spread = ext[2]; in snd_opl3_load_patch()
286 patch->inst.trnsps = ext[3]; in snd_opl3_load_patch()
287 patch->inst.fix_dur = ext[4]; in snd_opl3_load_patch()
288 patch->inst.modes = ext[5]; in snd_opl3_load_patch()
289 patch->inst.fix_key = ext[6]; in snd_opl3_load_patch()
293 strlcpy(patch->name, name, sizeof(patch->name)); in snd_opl3_load_patch()
311 for (patch = opl3->patch_table[key]; patch; patch = patch->next) { in snd_opl3_find_patch()
312 if (patch->prog == prog && patch->bank == bank) in snd_opl3_find_patch()
321 patch->prog = prog; in snd_opl3_find_patch()
322 patch->bank = bank; in snd_opl3_find_patch()
323 patch->next = opl3->patch_table[key]; in snd_opl3_find_patch()
324 opl3->patch_table[key] = patch; in snd_opl3_find_patch()
337 for (patch = opl3->patch_table[i]; patch; patch = next) { in snd_opl3_clear_patches()
338 next = patch->next; in snd_opl3_clear_patches()
342 memset(opl3->patch_table, 0, sizeof(opl3->patch_table)); in snd_opl3_clear_patches()
346 /* ------------------------------ */
357 max_voices = (opl3->hardware < OPL3_HW_OPL3) ? in snd_opl3_reset()
369 voice_offset = i - MAX_OPL2_VOICES; in snd_opl3_reset()
372 opl3->command(opl3, opl3_reg, OPL3_TOTAL_LEVEL_MASK); /* Operator 1 volume */ in snd_opl3_reset()
374 opl3->command(opl3, opl3_reg, OPL3_TOTAL_LEVEL_MASK); /* Operator 2 volume */ in snd_opl3_reset()
377 opl3->command(opl3, opl3_reg, 0x00); /* Note off */ in snd_opl3_reset()
380 opl3->max_voices = MAX_OPL2_VOICES; in snd_opl3_reset()
381 opl3->fm_mode = SNDRV_DM_FM_MODE_OPL2; in snd_opl3_reset()
383 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TEST, OPL3_ENABLE_WAVE_SELECT); in snd_opl3_reset()
384 opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION, 0x00); /* Melodic mode */ in snd_opl3_reset()
385 opl3->rhythm = 0; in snd_opl3_reset()
398 /* Voices 0 - 8 in OPL2 mode */ in snd_opl3_play_note()
399 /* Voices 0 - 17 in OPL3 mode */ in snd_opl3_play_note()
400 if (note->voice >= ((opl3->fm_mode == SNDRV_DM_FM_MODE_OPL3) ? in snd_opl3_play_note()
402 return -EINVAL; in snd_opl3_play_note()
405 if (note->voice < MAX_OPL2_VOICES) { in snd_opl3_play_note()
408 voice_offset = note->voice; in snd_opl3_play_note()
412 voice_offset = note->voice - MAX_OPL2_VOICES; in snd_opl3_play_note()
416 reg_val = (unsigned char) note->fnum; in snd_opl3_play_note()
418 opl3->command(opl3, opl3_reg, reg_val); in snd_opl3_play_note()
422 if (note->key_on) in snd_opl3_play_note()
425 reg_val |= (note->octave << 2) & OPL3_BLOCKNUM_MASK; in snd_opl3_play_note()
427 reg_val |= (unsigned char) (note->fnum >> 8) & OPL3_FNUM_HIGH_MASK; in snd_opl3_play_note()
431 opl3->command(opl3, opl3_reg, reg_val); in snd_opl3_play_note()
447 if (voice->op > 1) in snd_opl3_set_voice()
448 return -EINVAL; in snd_opl3_set_voice()
449 /* Voices 0 - 8 in OPL2 mode */ in snd_opl3_set_voice()
450 /* Voices 0 - 17 in OPL3 mode */ in snd_opl3_set_voice()
451 if (voice->voice >= ((opl3->fm_mode == SNDRV_DM_FM_MODE_OPL3) ? in snd_opl3_set_voice()
453 return -EINVAL; in snd_opl3_set_voice()
456 if (voice->voice < MAX_OPL2_VOICES) { in snd_opl3_set_voice()
459 voice_offset = voice->voice; in snd_opl3_set_voice()
463 voice_offset = voice->voice - MAX_OPL2_VOICES; in snd_opl3_set_voice()
467 voice_op = array_index_nospec(voice->op, 4); in snd_opl3_set_voice()
472 if (voice->am) in snd_opl3_set_voice()
475 if (voice->vibrato) in snd_opl3_set_voice()
478 if (voice->do_sustain) in snd_opl3_set_voice()
481 if (voice->kbd_scale) in snd_opl3_set_voice()
484 reg_val |= voice->harmonic & OPL3_MULTIPLE_MASK; in snd_opl3_set_voice()
488 opl3->command(opl3, opl3_reg, reg_val); in snd_opl3_set_voice()
491 reg_val = (voice->scale_level << 6) & OPL3_KSL_MASK; in snd_opl3_set_voice()
493 reg_val |= ~voice->volume & OPL3_TOTAL_LEVEL_MASK; in snd_opl3_set_voice()
497 opl3->command(opl3, opl3_reg, reg_val); in snd_opl3_set_voice()
500 reg_val = (voice->attack << 4) & OPL3_ATTACK_MASK; in snd_opl3_set_voice()
502 reg_val |= voice->decay & OPL3_DECAY_MASK; in snd_opl3_set_voice()
506 opl3->command(opl3, opl3_reg, reg_val); in snd_opl3_set_voice()
509 reg_val = (voice->sustain << 4) & OPL3_SUSTAIN_MASK; in snd_opl3_set_voice()
511 reg_val |= voice->release & OPL3_RELEASE_MASK; in snd_opl3_set_voice()
515 opl3->command(opl3, opl3_reg, reg_val); in snd_opl3_set_voice()
517 /* Set inter-operator feedback */ in snd_opl3_set_voice()
518 reg_val = (voice->feedback << 1) & OPL3_FEEDBACK_MASK; in snd_opl3_set_voice()
519 /* Set inter-operator connection */ in snd_opl3_set_voice()
520 if (voice->connection) in snd_opl3_set_voice()
522 /* OPL-3 only */ in snd_opl3_set_voice()
523 if (opl3->fm_mode == SNDRV_DM_FM_MODE_OPL3) { in snd_opl3_set_voice()
524 if (voice->left) in snd_opl3_set_voice()
526 if (voice->right) in snd_opl3_set_voice()
531 opl3->command(opl3, opl3_reg, reg_val); in snd_opl3_set_voice()
534 reg_val = voice->waveform & OPL3_WAVE_SELECT_MASK; in snd_opl3_set_voice()
536 opl3->command(opl3, opl3_reg, reg_val); in snd_opl3_set_voice()
547 if (params->kbd_split) in snd_opl3_set_params()
549 opl3->command(opl3, OPL3_LEFT | OPL3_REG_KBD_SPLIT, reg_val); in snd_opl3_set_params()
553 if (params->am_depth) in snd_opl3_set_params()
556 if (params->vib_depth) in snd_opl3_set_params()
558 /* Set percussion mode */ in snd_opl3_set_params()
559 if (params->rhythm) { in snd_opl3_set_params()
561 opl3->rhythm = 1; in snd_opl3_set_params()
563 opl3->rhythm = 0; in snd_opl3_set_params()
566 if (params->bass) in snd_opl3_set_params()
568 if (params->snare) in snd_opl3_set_params()
570 if (params->tomtom) in snd_opl3_set_params()
572 if (params->cymbal) in snd_opl3_set_params()
574 if (params->hihat) in snd_opl3_set_params()
577 opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION, reg_val); in snd_opl3_set_params()
581 static int snd_opl3_set_mode(struct snd_opl3 * opl3, int mode) in snd_opl3_set_mode() argument
583 if ((mode == SNDRV_DM_FM_MODE_OPL3) && (opl3->hardware < OPL3_HW_OPL3)) in snd_opl3_set_mode()
584 return -EINVAL; in snd_opl3_set_mode()
586 opl3->fm_mode = mode; in snd_opl3_set_mode()
587 if (opl3->hardware >= OPL3_HW_OPL3) in snd_opl3_set_mode()
588 opl3->command(opl3, OPL3_RIGHT | OPL3_REG_CONNECTION_SELECT, 0x00); /* Clear 4-op connections */ in snd_opl3_set_mode()
597 /* OPL-3 only */ in snd_opl3_set_connection()
598 if (opl3->fm_mode != SNDRV_DM_FM_MODE_OPL3) in snd_opl3_set_connection()
599 return -EINVAL; in snd_opl3_set_connection()
603 /* Set 4-op connections */ in snd_opl3_set_connection()
604 opl3->command(opl3, OPL3_RIGHT | OPL3_REG_CONNECTION_SELECT, reg_val); in snd_opl3_set_connection()