Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 #ifndef __SOUND_ASOUND_FM_H
0003 #define __SOUND_ASOUND_FM_H
0004 
0005 /*
0006  *  Advanced Linux Sound Architecture - ALSA
0007  *
0008  *  Interface file between ALSA driver & user space
0009  *  Copyright (c) 1994-98 by Jaroslav Kysela <perex@perex.cz>,
0010  *                           4Front Technologies
0011  *
0012  *  Direct FM control
0013  *
0014  *   This program is free software; you can redistribute it and/or modify
0015  *   it under the terms of the GNU General Public License as published by
0016  *   the Free Software Foundation; either version 2 of the License, or
0017  *   (at your option) any later version.
0018  *
0019  *   This program is distributed in the hope that it will be useful,
0020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0022  *   GNU General Public License for more details.
0023  *
0024  *   You should have received a copy of the GNU General Public License
0025  *   along with this program; if not, write to the Free Software
0026  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
0027  *
0028  */
0029 
0030 #define SNDRV_DM_FM_MODE_OPL2   0x00
0031 #define SNDRV_DM_FM_MODE_OPL3   0x01
0032 
0033 struct snd_dm_fm_info {
0034     unsigned char fm_mode;      /* OPL mode, see SNDRV_DM_FM_MODE_XXX */
0035     unsigned char rhythm;       /* percussion mode flag */
0036 };
0037 
0038 /*
0039  *  Data structure composing an FM "note" or sound event.
0040  */
0041 
0042 struct snd_dm_fm_voice {
0043     unsigned char op;       /* operator cell (0 or 1) */
0044     unsigned char voice;        /* FM voice (0 to 17) */
0045 
0046     unsigned char am;       /* amplitude modulation */
0047     unsigned char vibrato;      /* vibrato effect */
0048     unsigned char do_sustain;   /* sustain phase */
0049     unsigned char kbd_scale;    /* keyboard scaling */
0050     unsigned char harmonic;     /* 4 bits: harmonic and multiplier */
0051     unsigned char scale_level;  /* 2 bits: decrease output freq rises */
0052     unsigned char volume;       /* 6 bits: volume */
0053 
0054     unsigned char attack;       /* 4 bits: attack rate */
0055     unsigned char decay;        /* 4 bits: decay rate */
0056     unsigned char sustain;      /* 4 bits: sustain level */
0057     unsigned char release;      /* 4 bits: release rate */
0058 
0059     unsigned char feedback;     /* 3 bits: feedback for op0 */
0060     unsigned char connection;   /* 0 for serial, 1 for parallel */
0061     unsigned char left;     /* stereo left */
0062     unsigned char right;        /* stereo right */
0063     unsigned char waveform;     /* 3 bits: waveform shape */
0064 };
0065 
0066 /*
0067  *  This describes an FM note by its voice, octave, frequency number (10bit)
0068  *  and key on/off.
0069  */
0070 
0071 struct snd_dm_fm_note {
0072     unsigned char voice;    /* 0-17 voice channel */
0073     unsigned char octave;   /* 3 bits: what octave to play */
0074     unsigned int fnum;  /* 10 bits: frequency number */
0075     unsigned char key_on;   /* set for active, clear for silent */
0076 };
0077 
0078 /*
0079  *  FM parameters that apply globally to all voices, and thus are not "notes"
0080  */
0081 
0082 struct snd_dm_fm_params {
0083     unsigned char am_depth;     /* amplitude modulation depth (1=hi) */
0084     unsigned char vib_depth;    /* vibrato depth (1=hi) */
0085     unsigned char kbd_split;    /* keyboard split */
0086     unsigned char rhythm;       /* percussion mode select */
0087 
0088     /* This block is the percussion instrument data */
0089     unsigned char bass;
0090     unsigned char snare;
0091     unsigned char tomtom;
0092     unsigned char cymbal;
0093     unsigned char hihat;
0094 };
0095 
0096 /*
0097  *  FM mode ioctl settings
0098  */
0099 
0100 #define SNDRV_DM_FM_IOCTL_INFO      _IOR('H', 0x20, struct snd_dm_fm_info)
0101 #define SNDRV_DM_FM_IOCTL_RESET     _IO ('H', 0x21)
0102 #define SNDRV_DM_FM_IOCTL_PLAY_NOTE _IOW('H', 0x22, struct snd_dm_fm_note)
0103 #define SNDRV_DM_FM_IOCTL_SET_VOICE _IOW('H', 0x23, struct snd_dm_fm_voice)
0104 #define SNDRV_DM_FM_IOCTL_SET_PARAMS    _IOW('H', 0x24, struct snd_dm_fm_params)
0105 #define SNDRV_DM_FM_IOCTL_SET_MODE  _IOW('H', 0x25, int)
0106 /* for OPL3 only */
0107 #define SNDRV_DM_FM_IOCTL_SET_CONNECTION    _IOW('H', 0x26, int)
0108 /* SBI patch management */
0109 #define SNDRV_DM_FM_IOCTL_CLEAR_PATCHES _IO ('H', 0x40)
0110 
0111 #define SNDRV_DM_FM_OSS_IOCTL_RESET     0x20
0112 #define SNDRV_DM_FM_OSS_IOCTL_PLAY_NOTE     0x21
0113 #define SNDRV_DM_FM_OSS_IOCTL_SET_VOICE     0x22
0114 #define SNDRV_DM_FM_OSS_IOCTL_SET_PARAMS    0x23
0115 #define SNDRV_DM_FM_OSS_IOCTL_SET_MODE      0x24
0116 #define SNDRV_DM_FM_OSS_IOCTL_SET_OPL       0x25
0117 
0118 /*
0119  * Patch Record - fixed size for write
0120  */
0121 
0122 #define FM_KEY_SBI  "SBI\032"
0123 #define FM_KEY_2OP  "2OP\032"
0124 #define FM_KEY_4OP  "4OP\032"
0125 
0126 struct sbi_patch {
0127     unsigned char prog;
0128     unsigned char bank;
0129     char key[4];
0130     char name[25];
0131     char extension[7];
0132     unsigned char data[32];
0133 };
0134 
0135 #endif /* __SOUND_ASOUND_FM_H */