xref: /openbmc/linux/include/uapi/sound/sfnt_info.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1*e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2674e95caSDavid Howells #ifndef __SOUND_SFNT_INFO_H
3674e95caSDavid Howells #define __SOUND_SFNT_INFO_H
4674e95caSDavid Howells 
5674e95caSDavid Howells /*
6674e95caSDavid Howells  *  Patch record compatible with AWE driver on OSS
7674e95caSDavid Howells  *
8674e95caSDavid Howells  *  Copyright (C) 1999-2000 Takashi Iwai
9674e95caSDavid Howells  */
10674e95caSDavid Howells 
11674e95caSDavid Howells #include <sound/asound.h>
12674e95caSDavid Howells 
13674e95caSDavid Howells /*
14674e95caSDavid Howells  * patch information record
15674e95caSDavid Howells  */
16674e95caSDavid Howells 
17674e95caSDavid Howells #ifdef SNDRV_BIG_ENDIAN
18674e95caSDavid Howells #define SNDRV_OSS_PATCHKEY(id) (0xfd00|id)
19674e95caSDavid Howells #else
20674e95caSDavid Howells #define SNDRV_OSS_PATCHKEY(id) ((id<<8)|0xfd)
21674e95caSDavid Howells #endif
22674e95caSDavid Howells 
23674e95caSDavid Howells /* patch interface header: 16 bytes */
24674e95caSDavid Howells struct soundfont_patch_info {
25674e95caSDavid Howells 	unsigned short key;		/* use the key below */
26674e95caSDavid Howells #define SNDRV_OSS_SOUNDFONT_PATCH		SNDRV_OSS_PATCHKEY(0x07)
27674e95caSDavid Howells 
28674e95caSDavid Howells 	short device_no;		/* synthesizer number */
29674e95caSDavid Howells 	unsigned short sf_id;		/* file id (should be zero) */
30674e95caSDavid Howells 	short optarg;			/* optional argument */
31674e95caSDavid Howells 	int len;			/* data length (without this header) */
32674e95caSDavid Howells 
33674e95caSDavid Howells 	short type;			/* patch operation type */
34674e95caSDavid Howells #define SNDRV_SFNT_LOAD_INFO		0	/* awe_voice_rec */
35674e95caSDavid Howells #define SNDRV_SFNT_LOAD_DATA		1	/* awe_sample_info */
36674e95caSDavid Howells #define SNDRV_SFNT_OPEN_PATCH	2	/* awe_open_parm */
37674e95caSDavid Howells #define SNDRV_SFNT_CLOSE_PATCH	3	/* none */
38674e95caSDavid Howells 	/* 4 is obsolete */
39674e95caSDavid Howells #define SNDRV_SFNT_REPLACE_DATA	5	/* awe_sample_info (optarg=#channels)*/
40674e95caSDavid Howells #define SNDRV_SFNT_MAP_PRESET	6	/* awe_voice_map */
41674e95caSDavid Howells 	/* 7 is not used */
42674e95caSDavid Howells #define SNDRV_SFNT_PROBE_DATA		8	/* optarg=sample */
43674e95caSDavid Howells #define SNDRV_SFNT_REMOVE_INFO		9	/* optarg=(bank<<8)|instr */
44674e95caSDavid Howells 
45674e95caSDavid Howells 	short reserved;			/* word alignment data */
46674e95caSDavid Howells 
47674e95caSDavid Howells 	/* the actual patch data begins after this */
48674e95caSDavid Howells };
49674e95caSDavid Howells 
50674e95caSDavid Howells 
51674e95caSDavid Howells /*
52674e95caSDavid Howells  * open patch
53674e95caSDavid Howells  */
54674e95caSDavid Howells 
55674e95caSDavid Howells #define SNDRV_SFNT_PATCH_NAME_LEN	32
56674e95caSDavid Howells 
57674e95caSDavid Howells struct soundfont_open_parm {
58674e95caSDavid Howells 	unsigned short type;		/* sample type */
59674e95caSDavid Howells #define SNDRV_SFNT_PAT_TYPE_MISC	0
60674e95caSDavid Howells #define SNDRV_SFNT_PAT_TYPE_GUS	6
61674e95caSDavid Howells #define SNDRV_SFNT_PAT_TYPE_MAP	7
62674e95caSDavid Howells #define SNDRV_SFNT_PAT_LOCKED	0x100	/* lock the samples */
63674e95caSDavid Howells #define SNDRV_SFNT_PAT_SHARED	0x200	/* sample is shared */
64674e95caSDavid Howells 
65674e95caSDavid Howells 	short reserved;
66674e95caSDavid Howells 	char name[SNDRV_SFNT_PATCH_NAME_LEN];
67674e95caSDavid Howells };
68674e95caSDavid Howells 
69674e95caSDavid Howells 
70674e95caSDavid Howells /*
71674e95caSDavid Howells  * raw voice information record
72674e95caSDavid Howells  */
73674e95caSDavid Howells 
74674e95caSDavid Howells /* wave table envelope & effect parameters to control EMU8000 */
75674e95caSDavid Howells struct soundfont_voice_parm {
76674e95caSDavid Howells 	unsigned short moddelay;	/* modulation delay (0x8000) */
77674e95caSDavid Howells 	unsigned short modatkhld;	/* modulation attack & hold time (0x7f7f) */
78674e95caSDavid Howells 	unsigned short moddcysus;	/* modulation decay & sustain (0x7f7f) */
79674e95caSDavid Howells 	unsigned short modrelease;	/* modulation release time (0x807f) */
80674e95caSDavid Howells 	short modkeyhold, modkeydecay;	/* envelope change per key (not used) */
81674e95caSDavid Howells 	unsigned short voldelay;	/* volume delay (0x8000) */
82674e95caSDavid Howells 	unsigned short volatkhld;	/* volume attack & hold time (0x7f7f) */
83674e95caSDavid Howells 	unsigned short voldcysus;	/* volume decay & sustain (0x7f7f) */
84674e95caSDavid Howells 	unsigned short volrelease;	/* volume release time (0x807f) */
85674e95caSDavid Howells 	short volkeyhold, volkeydecay;	/* envelope change per key (not used) */
86674e95caSDavid Howells 	unsigned short lfo1delay;	/* LFO1 delay (0x8000) */
87674e95caSDavid Howells 	unsigned short lfo2delay;	/* LFO2 delay (0x8000) */
88674e95caSDavid Howells 	unsigned short pefe;		/* modulation pitch & cutoff (0x0000) */
89674e95caSDavid Howells 	unsigned short fmmod;		/* LFO1 pitch & cutoff (0x0000) */
90674e95caSDavid Howells 	unsigned short tremfrq;		/* LFO1 volume & freq (0x0000) */
91674e95caSDavid Howells 	unsigned short fm2frq2;		/* LFO2 pitch & freq (0x0000) */
92674e95caSDavid Howells 	unsigned char cutoff;		/* initial cutoff (0xff) */
93674e95caSDavid Howells 	unsigned char filterQ;		/* initial filter Q [0-15] (0x0) */
94674e95caSDavid Howells 	unsigned char chorus;		/* chorus send (0x00) */
95674e95caSDavid Howells 	unsigned char reverb;		/* reverb send (0x00) */
96674e95caSDavid Howells 	unsigned short reserved[4];	/* not used */
97674e95caSDavid Howells };
98674e95caSDavid Howells 
99674e95caSDavid Howells 
100674e95caSDavid Howells /* wave table parameters: 92 bytes */
101674e95caSDavid Howells struct soundfont_voice_info {
102674e95caSDavid Howells 	unsigned short sf_id;		/* file id (should be zero) */
103674e95caSDavid Howells 	unsigned short sample;		/* sample id */
104674e95caSDavid Howells 	int start, end;			/* sample offset correction */
105674e95caSDavid Howells 	int loopstart, loopend;		/* loop offset correction */
106674e95caSDavid Howells 	short rate_offset;		/* sample rate pitch offset */
107674e95caSDavid Howells 	unsigned short mode;		/* sample mode */
108674e95caSDavid Howells #define SNDRV_SFNT_MODE_ROMSOUND		0x8000
109674e95caSDavid Howells #define SNDRV_SFNT_MODE_STEREO		1
110674e95caSDavid Howells #define SNDRV_SFNT_MODE_LOOPING		2
111674e95caSDavid Howells #define SNDRV_SFNT_MODE_NORELEASE		4	/* obsolete */
112674e95caSDavid Howells #define SNDRV_SFNT_MODE_INIT_PARM		8
113674e95caSDavid Howells 
114674e95caSDavid Howells 	short root;			/* midi root key */
115674e95caSDavid Howells 	short tune;			/* pitch tuning (in cents) */
116674e95caSDavid Howells 	unsigned char low, high;	/* key note range */
117674e95caSDavid Howells 	unsigned char vellow, velhigh;	/* velocity range */
118674e95caSDavid Howells 	signed char fixkey, fixvel;	/* fixed key, velocity */
119674e95caSDavid Howells 	signed char pan, fixpan;	/* panning, fixed panning */
120674e95caSDavid Howells 	short exclusiveClass;		/* exclusive class (0 = none) */
121674e95caSDavid Howells 	unsigned char amplitude;	/* sample volume (127 max) */
122674e95caSDavid Howells 	unsigned char attenuation;	/* attenuation (0.375dB) */
123674e95caSDavid Howells 	short scaleTuning;		/* pitch scale tuning(%), normally 100 */
124674e95caSDavid Howells 	struct soundfont_voice_parm parm;	/* voice envelope parameters */
125674e95caSDavid Howells 	unsigned short sample_mode;	/* sample mode_flag (set by driver) */
126674e95caSDavid Howells };
127674e95caSDavid Howells 
128674e95caSDavid Howells 
129674e95caSDavid Howells /* instrument info header: 4 bytes */
130674e95caSDavid Howells struct soundfont_voice_rec_hdr {
131674e95caSDavid Howells 	unsigned char bank;		/* midi bank number */
132674e95caSDavid Howells 	unsigned char instr;		/* midi preset number */
133674e95caSDavid Howells 	char nvoices;			/* number of voices */
134674e95caSDavid Howells 	char write_mode;		/* write mode; normally 0 */
135674e95caSDavid Howells #define SNDRV_SFNT_WR_APPEND		0	/* append anyway */
136674e95caSDavid Howells #define SNDRV_SFNT_WR_EXCLUSIVE		1	/* skip if already exists */
137674e95caSDavid Howells #define SNDRV_SFNT_WR_REPLACE		2	/* replace if already exists */
138674e95caSDavid Howells };
139674e95caSDavid Howells 
140674e95caSDavid Howells 
141674e95caSDavid Howells /*
142674e95caSDavid Howells  * sample wave information
143674e95caSDavid Howells  */
144674e95caSDavid Howells 
145674e95caSDavid Howells /* wave table sample header: 32 bytes */
146674e95caSDavid Howells struct soundfont_sample_info {
147674e95caSDavid Howells 	unsigned short sf_id;		/* file id (should be zero) */
148674e95caSDavid Howells 	unsigned short sample;		/* sample id */
149674e95caSDavid Howells 	int start, end;			/* start & end offset */
150674e95caSDavid Howells 	int loopstart, loopend;		/* loop start & end offset */
151674e95caSDavid Howells 	int size;			/* size (0 = ROM) */
152674e95caSDavid Howells 	short dummy;			/* not used */
153674e95caSDavid Howells 	unsigned short mode_flags;	/* mode flags */
154674e95caSDavid Howells #define SNDRV_SFNT_SAMPLE_8BITS		1	/* wave data is 8bits */
155674e95caSDavid Howells #define SNDRV_SFNT_SAMPLE_UNSIGNED	2	/* wave data is unsigned */
156674e95caSDavid Howells #define SNDRV_SFNT_SAMPLE_NO_BLANK	4	/* no blank loop is attached */
157674e95caSDavid Howells #define SNDRV_SFNT_SAMPLE_SINGLESHOT	8	/* single-shot w/o loop */
158674e95caSDavid Howells #define SNDRV_SFNT_SAMPLE_BIDIR_LOOP	16	/* bidirectional looping */
159674e95caSDavid Howells #define SNDRV_SFNT_SAMPLE_STEREO_LEFT	32	/* stereo left sound */
160674e95caSDavid Howells #define SNDRV_SFNT_SAMPLE_STEREO_RIGHT	64	/* stereo right sound */
161674e95caSDavid Howells #define SNDRV_SFNT_SAMPLE_REVERSE_LOOP	128	/* reverse looping */
162674e95caSDavid Howells 	unsigned int truesize;		/* used memory size (set by driver) */
163674e95caSDavid Howells };
164674e95caSDavid Howells 
165674e95caSDavid Howells 
166674e95caSDavid Howells /*
167674e95caSDavid Howells  * voice preset mapping (aliasing)
168674e95caSDavid Howells  */
169674e95caSDavid Howells 
170674e95caSDavid Howells struct soundfont_voice_map {
171674e95caSDavid Howells 	int map_bank, map_instr, map_key;	/* key = -1 means all keys */
172674e95caSDavid Howells 	int src_bank, src_instr, src_key;
173674e95caSDavid Howells };
174674e95caSDavid Howells 
175674e95caSDavid Howells 
176674e95caSDavid Howells /*
177674e95caSDavid Howells  * ioctls for hwdep
178674e95caSDavid Howells  */
179674e95caSDavid Howells 
180674e95caSDavid Howells #define SNDRV_EMUX_HWDEP_NAME	"Emux WaveTable"
181674e95caSDavid Howells 
182674e95caSDavid Howells #define SNDRV_EMUX_VERSION	((1 << 16) | (0 << 8) | 0)	/* 1.0.0 */
183674e95caSDavid Howells 
184674e95caSDavid Howells struct snd_emux_misc_mode {
185674e95caSDavid Howells 	int port;	/* -1 = all */
186674e95caSDavid Howells 	int mode;
187674e95caSDavid Howells 	int value;
188674e95caSDavid Howells 	int value2;	/* reserved */
189674e95caSDavid Howells };
190674e95caSDavid Howells 
191674e95caSDavid Howells #define SNDRV_EMUX_IOCTL_VERSION	_IOR('H', 0x80, unsigned int)
192674e95caSDavid Howells #define SNDRV_EMUX_IOCTL_LOAD_PATCH	_IOWR('H', 0x81, struct soundfont_patch_info)
193674e95caSDavid Howells #define SNDRV_EMUX_IOCTL_RESET_SAMPLES	_IO('H', 0x82)
194674e95caSDavid Howells #define SNDRV_EMUX_IOCTL_REMOVE_LAST_SAMPLES _IO('H', 0x83)
195674e95caSDavid Howells #define SNDRV_EMUX_IOCTL_MEM_AVAIL	_IOW('H', 0x84, int)
196674e95caSDavid Howells #define SNDRV_EMUX_IOCTL_MISC_MODE	_IOWR('H', 0x84, struct snd_emux_misc_mode)
197674e95caSDavid Howells 
198674e95caSDavid Howells #endif /* __SOUND_SFNT_INFO_H */
199