xref: /openbmc/linux/include/uapi/sound/sfnt_info.h (revision 4a075bd4)
1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 #ifndef __SOUND_SFNT_INFO_H
3 #define __SOUND_SFNT_INFO_H
4 
5 /*
6  *  Patch record compatible with AWE driver on OSS
7  *
8  *  Copyright (C) 1999-2000 Takashi Iwai
9  *
10  *   This program is free software; you can redistribute it and/or modify
11  *   it under the terms of the GNU General Public License as published by
12  *   the Free Software Foundation; either version 2 of the License, or
13  *   (at your option) any later version.
14  *
15  *   This program is distributed in the hope that it will be useful,
16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *   GNU General Public License for more details.
19  *
20  *   You should have received a copy of the GNU General Public License
21  *   along with this program; if not, write to the Free Software
22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23  *
24  */
25 
26 #include <sound/asound.h>
27 
28 /*
29  * patch information record
30  */
31 
32 #ifdef SNDRV_BIG_ENDIAN
33 #define SNDRV_OSS_PATCHKEY(id) (0xfd00|id)
34 #else
35 #define SNDRV_OSS_PATCHKEY(id) ((id<<8)|0xfd)
36 #endif
37 
38 /* patch interface header: 16 bytes */
39 struct soundfont_patch_info {
40 	unsigned short key;		/* use the key below */
41 #define SNDRV_OSS_SOUNDFONT_PATCH		SNDRV_OSS_PATCHKEY(0x07)
42 
43 	short device_no;		/* synthesizer number */
44 	unsigned short sf_id;		/* file id (should be zero) */
45 	short optarg;			/* optional argument */
46 	int len;			/* data length (without this header) */
47 
48 	short type;			/* patch operation type */
49 #define SNDRV_SFNT_LOAD_INFO		0	/* awe_voice_rec */
50 #define SNDRV_SFNT_LOAD_DATA		1	/* awe_sample_info */
51 #define SNDRV_SFNT_OPEN_PATCH	2	/* awe_open_parm */
52 #define SNDRV_SFNT_CLOSE_PATCH	3	/* none */
53 	/* 4 is obsolete */
54 #define SNDRV_SFNT_REPLACE_DATA	5	/* awe_sample_info (optarg=#channels)*/
55 #define SNDRV_SFNT_MAP_PRESET	6	/* awe_voice_map */
56 	/* 7 is not used */
57 #define SNDRV_SFNT_PROBE_DATA		8	/* optarg=sample */
58 #define SNDRV_SFNT_REMOVE_INFO		9	/* optarg=(bank<<8)|instr */
59 
60 	short reserved;			/* word alignment data */
61 
62 	/* the actual patch data begins after this */
63 };
64 
65 
66 /*
67  * open patch
68  */
69 
70 #define SNDRV_SFNT_PATCH_NAME_LEN	32
71 
72 struct soundfont_open_parm {
73 	unsigned short type;		/* sample type */
74 #define SNDRV_SFNT_PAT_TYPE_MISC	0
75 #define SNDRV_SFNT_PAT_TYPE_GUS	6
76 #define SNDRV_SFNT_PAT_TYPE_MAP	7
77 #define SNDRV_SFNT_PAT_LOCKED	0x100	/* lock the samples */
78 #define SNDRV_SFNT_PAT_SHARED	0x200	/* sample is shared */
79 
80 	short reserved;
81 	char name[SNDRV_SFNT_PATCH_NAME_LEN];
82 };
83 
84 
85 /*
86  * raw voice information record
87  */
88 
89 /* wave table envelope & effect parameters to control EMU8000 */
90 struct soundfont_voice_parm {
91 	unsigned short moddelay;	/* modulation delay (0x8000) */
92 	unsigned short modatkhld;	/* modulation attack & hold time (0x7f7f) */
93 	unsigned short moddcysus;	/* modulation decay & sustain (0x7f7f) */
94 	unsigned short modrelease;	/* modulation release time (0x807f) */
95 	short modkeyhold, modkeydecay;	/* envelope change per key (not used) */
96 	unsigned short voldelay;	/* volume delay (0x8000) */
97 	unsigned short volatkhld;	/* volume attack & hold time (0x7f7f) */
98 	unsigned short voldcysus;	/* volume decay & sustain (0x7f7f) */
99 	unsigned short volrelease;	/* volume release time (0x807f) */
100 	short volkeyhold, volkeydecay;	/* envelope change per key (not used) */
101 	unsigned short lfo1delay;	/* LFO1 delay (0x8000) */
102 	unsigned short lfo2delay;	/* LFO2 delay (0x8000) */
103 	unsigned short pefe;		/* modulation pitch & cutoff (0x0000) */
104 	unsigned short fmmod;		/* LFO1 pitch & cutoff (0x0000) */
105 	unsigned short tremfrq;		/* LFO1 volume & freq (0x0000) */
106 	unsigned short fm2frq2;		/* LFO2 pitch & freq (0x0000) */
107 	unsigned char cutoff;		/* initial cutoff (0xff) */
108 	unsigned char filterQ;		/* initial filter Q [0-15] (0x0) */
109 	unsigned char chorus;		/* chorus send (0x00) */
110 	unsigned char reverb;		/* reverb send (0x00) */
111 	unsigned short reserved[4];	/* not used */
112 };
113 
114 
115 /* wave table parameters: 92 bytes */
116 struct soundfont_voice_info {
117 	unsigned short sf_id;		/* file id (should be zero) */
118 	unsigned short sample;		/* sample id */
119 	int start, end;			/* sample offset correction */
120 	int loopstart, loopend;		/* loop offset correction */
121 	short rate_offset;		/* sample rate pitch offset */
122 	unsigned short mode;		/* sample mode */
123 #define SNDRV_SFNT_MODE_ROMSOUND		0x8000
124 #define SNDRV_SFNT_MODE_STEREO		1
125 #define SNDRV_SFNT_MODE_LOOPING		2
126 #define SNDRV_SFNT_MODE_NORELEASE		4	/* obsolete */
127 #define SNDRV_SFNT_MODE_INIT_PARM		8
128 
129 	short root;			/* midi root key */
130 	short tune;			/* pitch tuning (in cents) */
131 	unsigned char low, high;	/* key note range */
132 	unsigned char vellow, velhigh;	/* velocity range */
133 	signed char fixkey, fixvel;	/* fixed key, velocity */
134 	signed char pan, fixpan;	/* panning, fixed panning */
135 	short exclusiveClass;		/* exclusive class (0 = none) */
136 	unsigned char amplitude;	/* sample volume (127 max) */
137 	unsigned char attenuation;	/* attenuation (0.375dB) */
138 	short scaleTuning;		/* pitch scale tuning(%), normally 100 */
139 	struct soundfont_voice_parm parm;	/* voice envelope parameters */
140 	unsigned short sample_mode;	/* sample mode_flag (set by driver) */
141 };
142 
143 
144 /* instrument info header: 4 bytes */
145 struct soundfont_voice_rec_hdr {
146 	unsigned char bank;		/* midi bank number */
147 	unsigned char instr;		/* midi preset number */
148 	char nvoices;			/* number of voices */
149 	char write_mode;		/* write mode; normally 0 */
150 #define SNDRV_SFNT_WR_APPEND		0	/* append anyway */
151 #define SNDRV_SFNT_WR_EXCLUSIVE		1	/* skip if already exists */
152 #define SNDRV_SFNT_WR_REPLACE		2	/* replace if already exists */
153 };
154 
155 
156 /*
157  * sample wave information
158  */
159 
160 /* wave table sample header: 32 bytes */
161 struct soundfont_sample_info {
162 	unsigned short sf_id;		/* file id (should be zero) */
163 	unsigned short sample;		/* sample id */
164 	int start, end;			/* start & end offset */
165 	int loopstart, loopend;		/* loop start & end offset */
166 	int size;			/* size (0 = ROM) */
167 	short dummy;			/* not used */
168 	unsigned short mode_flags;	/* mode flags */
169 #define SNDRV_SFNT_SAMPLE_8BITS		1	/* wave data is 8bits */
170 #define SNDRV_SFNT_SAMPLE_UNSIGNED	2	/* wave data is unsigned */
171 #define SNDRV_SFNT_SAMPLE_NO_BLANK	4	/* no blank loop is attached */
172 #define SNDRV_SFNT_SAMPLE_SINGLESHOT	8	/* single-shot w/o loop */
173 #define SNDRV_SFNT_SAMPLE_BIDIR_LOOP	16	/* bidirectional looping */
174 #define SNDRV_SFNT_SAMPLE_STEREO_LEFT	32	/* stereo left sound */
175 #define SNDRV_SFNT_SAMPLE_STEREO_RIGHT	64	/* stereo right sound */
176 #define SNDRV_SFNT_SAMPLE_REVERSE_LOOP	128	/* reverse looping */
177 	unsigned int truesize;		/* used memory size (set by driver) */
178 };
179 
180 
181 /*
182  * voice preset mapping (aliasing)
183  */
184 
185 struct soundfont_voice_map {
186 	int map_bank, map_instr, map_key;	/* key = -1 means all keys */
187 	int src_bank, src_instr, src_key;
188 };
189 
190 
191 /*
192  * ioctls for hwdep
193  */
194 
195 #define SNDRV_EMUX_HWDEP_NAME	"Emux WaveTable"
196 
197 #define SNDRV_EMUX_VERSION	((1 << 16) | (0 << 8) | 0)	/* 1.0.0 */
198 
199 struct snd_emux_misc_mode {
200 	int port;	/* -1 = all */
201 	int mode;
202 	int value;
203 	int value2;	/* reserved */
204 };
205 
206 #define SNDRV_EMUX_IOCTL_VERSION	_IOR('H', 0x80, unsigned int)
207 #define SNDRV_EMUX_IOCTL_LOAD_PATCH	_IOWR('H', 0x81, struct soundfont_patch_info)
208 #define SNDRV_EMUX_IOCTL_RESET_SAMPLES	_IO('H', 0x82)
209 #define SNDRV_EMUX_IOCTL_REMOVE_LAST_SAMPLES _IO('H', 0x83)
210 #define SNDRV_EMUX_IOCTL_MEM_AVAIL	_IOW('H', 0x84, int)
211 #define SNDRV_EMUX_IOCTL_MISC_MODE	_IOWR('H', 0x84, struct snd_emux_misc_mode)
212 
213 #endif /* __SOUND_SFNT_INFO_H */
214