^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __SOUND_ASOUND_FM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __SOUND_ASOUND_FM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Advanced Linux Sound Architecture - ALSA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Interface file between ALSA driver & user space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Copyright (c) 1994-98 by Jaroslav Kysela <perex@perex.cz>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * 4Front Technologies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Direct FM control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * it under the terms of the GNU General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * the Free Software Foundation; either version 2 of the License, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * You should have received a copy of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * along with this program; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define SNDRV_DM_FM_MODE_OPL2 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define SNDRV_DM_FM_MODE_OPL3 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct snd_dm_fm_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) unsigned char fm_mode; /* OPL mode, see SNDRV_DM_FM_MODE_XXX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) unsigned char rhythm; /* percussion mode flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * Data structure composing an FM "note" or sound event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct snd_dm_fm_voice {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) unsigned char op; /* operator cell (0 or 1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) unsigned char voice; /* FM voice (0 to 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) unsigned char am; /* amplitude modulation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) unsigned char vibrato; /* vibrato effect */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) unsigned char do_sustain; /* sustain phase */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) unsigned char kbd_scale; /* keyboard scaling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) unsigned char harmonic; /* 4 bits: harmonic and multiplier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) unsigned char scale_level; /* 2 bits: decrease output freq rises */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) unsigned char volume; /* 6 bits: volume */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) unsigned char attack; /* 4 bits: attack rate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) unsigned char decay; /* 4 bits: decay rate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) unsigned char sustain; /* 4 bits: sustain level */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) unsigned char release; /* 4 bits: release rate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) unsigned char feedback; /* 3 bits: feedback for op0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) unsigned char connection; /* 0 for serial, 1 for parallel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) unsigned char left; /* stereo left */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) unsigned char right; /* stereo right */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) unsigned char waveform; /* 3 bits: waveform shape */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * This describes an FM note by its voice, octave, frequency number (10bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * and key on/off.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct snd_dm_fm_note {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) unsigned char voice; /* 0-17 voice channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) unsigned char octave; /* 3 bits: what octave to play */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) unsigned int fnum; /* 10 bits: frequency number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) unsigned char key_on; /* set for active, clear for silent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * FM parameters that apply globally to all voices, and thus are not "notes"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct snd_dm_fm_params {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) unsigned char am_depth; /* amplitude modulation depth (1=hi) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) unsigned char vib_depth; /* vibrato depth (1=hi) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) unsigned char kbd_split; /* keyboard split */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) unsigned char rhythm; /* percussion mode select */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /* This block is the percussion instrument data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) unsigned char bass;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) unsigned char snare;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) unsigned char tomtom;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) unsigned char cymbal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) unsigned char hihat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * FM mode ioctl settings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define SNDRV_DM_FM_IOCTL_INFO _IOR('H', 0x20, struct snd_dm_fm_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define SNDRV_DM_FM_IOCTL_RESET _IO ('H', 0x21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define SNDRV_DM_FM_IOCTL_PLAY_NOTE _IOW('H', 0x22, struct snd_dm_fm_note)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define SNDRV_DM_FM_IOCTL_SET_VOICE _IOW('H', 0x23, struct snd_dm_fm_voice)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define SNDRV_DM_FM_IOCTL_SET_PARAMS _IOW('H', 0x24, struct snd_dm_fm_params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define SNDRV_DM_FM_IOCTL_SET_MODE _IOW('H', 0x25, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /* for OPL3 only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define SNDRV_DM_FM_IOCTL_SET_CONNECTION _IOW('H', 0x26, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /* SBI patch management */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define SNDRV_DM_FM_IOCTL_CLEAR_PATCHES _IO ('H', 0x40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define SNDRV_DM_FM_OSS_IOCTL_RESET 0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #define SNDRV_DM_FM_OSS_IOCTL_PLAY_NOTE 0x21
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define SNDRV_DM_FM_OSS_IOCTL_SET_VOICE 0x22
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define SNDRV_DM_FM_OSS_IOCTL_SET_PARAMS 0x23
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define SNDRV_DM_FM_OSS_IOCTL_SET_MODE 0x24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define SNDRV_DM_FM_OSS_IOCTL_SET_OPL 0x25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * Patch Record - fixed size for write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define FM_KEY_SBI "SBI\032"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define FM_KEY_2OP "2OP\032"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define FM_KEY_4OP "4OP\032"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct sbi_patch {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) unsigned char prog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) unsigned char bank;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) char key[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) char name[25];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) char extension[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) unsigned char data[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #endif /* __SOUND_ASOUND_FM_H */