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