xref: /openbmc/linux/include/uapi/sound/asound_fm.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1*e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2674e95caSDavid Howells #ifndef __SOUND_ASOUND_FM_H
3674e95caSDavid Howells #define __SOUND_ASOUND_FM_H
4674e95caSDavid Howells 
5674e95caSDavid Howells /*
6674e95caSDavid Howells  *  Advanced Linux Sound Architecture - ALSA
7674e95caSDavid Howells  *
8674e95caSDavid Howells  *  Interface file between ALSA driver & user space
9674e95caSDavid Howells  *  Copyright (c) 1994-98 by Jaroslav Kysela <perex@perex.cz>,
10674e95caSDavid Howells  *                           4Front Technologies
11674e95caSDavid Howells  *
12674e95caSDavid Howells  *  Direct FM control
13674e95caSDavid Howells  */
14674e95caSDavid Howells 
15674e95caSDavid Howells #define SNDRV_DM_FM_MODE_OPL2	0x00
16674e95caSDavid Howells #define SNDRV_DM_FM_MODE_OPL3	0x01
17674e95caSDavid Howells 
18674e95caSDavid Howells struct snd_dm_fm_info {
19674e95caSDavid Howells 	unsigned char fm_mode;		/* OPL mode, see SNDRV_DM_FM_MODE_XXX */
20674e95caSDavid Howells 	unsigned char rhythm;		/* percussion mode flag */
21674e95caSDavid Howells };
22674e95caSDavid Howells 
23674e95caSDavid Howells /*
24674e95caSDavid Howells  *  Data structure composing an FM "note" or sound event.
25674e95caSDavid Howells  */
26674e95caSDavid Howells 
27674e95caSDavid Howells struct snd_dm_fm_voice {
28674e95caSDavid Howells 	unsigned char op;		/* operator cell (0 or 1) */
29674e95caSDavid Howells 	unsigned char voice;		/* FM voice (0 to 17) */
30674e95caSDavid Howells 
31674e95caSDavid Howells 	unsigned char am;		/* amplitude modulation */
32674e95caSDavid Howells 	unsigned char vibrato;		/* vibrato effect */
33674e95caSDavid Howells 	unsigned char do_sustain;	/* sustain phase */
34674e95caSDavid Howells 	unsigned char kbd_scale;	/* keyboard scaling */
35674e95caSDavid Howells 	unsigned char harmonic;		/* 4 bits: harmonic and multiplier */
36674e95caSDavid Howells 	unsigned char scale_level;	/* 2 bits: decrease output freq rises */
37674e95caSDavid Howells 	unsigned char volume;		/* 6 bits: volume */
38674e95caSDavid Howells 
39674e95caSDavid Howells 	unsigned char attack;		/* 4 bits: attack rate */
40674e95caSDavid Howells 	unsigned char decay;		/* 4 bits: decay rate */
41674e95caSDavid Howells 	unsigned char sustain;		/* 4 bits: sustain level */
42674e95caSDavid Howells 	unsigned char release;		/* 4 bits: release rate */
43674e95caSDavid Howells 
44674e95caSDavid Howells 	unsigned char feedback;		/* 3 bits: feedback for op0 */
45674e95caSDavid Howells 	unsigned char connection;	/* 0 for serial, 1 for parallel */
46674e95caSDavid Howells 	unsigned char left;		/* stereo left */
47674e95caSDavid Howells 	unsigned char right;		/* stereo right */
48674e95caSDavid Howells 	unsigned char waveform;		/* 3 bits: waveform shape */
49674e95caSDavid Howells };
50674e95caSDavid Howells 
51674e95caSDavid Howells /*
52674e95caSDavid Howells  *  This describes an FM note by its voice, octave, frequency number (10bit)
53674e95caSDavid Howells  *  and key on/off.
54674e95caSDavid Howells  */
55674e95caSDavid Howells 
56674e95caSDavid Howells struct snd_dm_fm_note {
57674e95caSDavid Howells 	unsigned char voice;	/* 0-17 voice channel */
58674e95caSDavid Howells 	unsigned char octave;	/* 3 bits: what octave to play */
59674e95caSDavid Howells 	unsigned int fnum;	/* 10 bits: frequency number */
60674e95caSDavid Howells 	unsigned char key_on;	/* set for active, clear for silent */
61674e95caSDavid Howells };
62674e95caSDavid Howells 
63674e95caSDavid Howells /*
64674e95caSDavid Howells  *  FM parameters that apply globally to all voices, and thus are not "notes"
65674e95caSDavid Howells  */
66674e95caSDavid Howells 
67674e95caSDavid Howells struct snd_dm_fm_params {
68674e95caSDavid Howells 	unsigned char am_depth;		/* amplitude modulation depth (1=hi) */
69674e95caSDavid Howells 	unsigned char vib_depth;	/* vibrato depth (1=hi) */
70674e95caSDavid Howells 	unsigned char kbd_split;	/* keyboard split */
71674e95caSDavid Howells 	unsigned char rhythm;		/* percussion mode select */
72674e95caSDavid Howells 
73674e95caSDavid Howells 	/* This block is the percussion instrument data */
74674e95caSDavid Howells 	unsigned char bass;
75674e95caSDavid Howells 	unsigned char snare;
76674e95caSDavid Howells 	unsigned char tomtom;
77674e95caSDavid Howells 	unsigned char cymbal;
78674e95caSDavid Howells 	unsigned char hihat;
79674e95caSDavid Howells };
80674e95caSDavid Howells 
81674e95caSDavid Howells /*
82674e95caSDavid Howells  *  FM mode ioctl settings
83674e95caSDavid Howells  */
84674e95caSDavid Howells 
85674e95caSDavid Howells #define SNDRV_DM_FM_IOCTL_INFO		_IOR('H', 0x20, struct snd_dm_fm_info)
86674e95caSDavid Howells #define SNDRV_DM_FM_IOCTL_RESET		_IO ('H', 0x21)
87674e95caSDavid Howells #define SNDRV_DM_FM_IOCTL_PLAY_NOTE	_IOW('H', 0x22, struct snd_dm_fm_note)
88674e95caSDavid Howells #define SNDRV_DM_FM_IOCTL_SET_VOICE	_IOW('H', 0x23, struct snd_dm_fm_voice)
89674e95caSDavid Howells #define SNDRV_DM_FM_IOCTL_SET_PARAMS	_IOW('H', 0x24, struct snd_dm_fm_params)
90674e95caSDavid Howells #define SNDRV_DM_FM_IOCTL_SET_MODE	_IOW('H', 0x25, int)
91674e95caSDavid Howells /* for OPL3 only */
92674e95caSDavid Howells #define SNDRV_DM_FM_IOCTL_SET_CONNECTION	_IOW('H', 0x26, int)
93674e95caSDavid Howells /* SBI patch management */
94674e95caSDavid Howells #define SNDRV_DM_FM_IOCTL_CLEAR_PATCHES	_IO ('H', 0x40)
95674e95caSDavid Howells 
96674e95caSDavid Howells #define SNDRV_DM_FM_OSS_IOCTL_RESET		0x20
97674e95caSDavid Howells #define SNDRV_DM_FM_OSS_IOCTL_PLAY_NOTE		0x21
98674e95caSDavid Howells #define SNDRV_DM_FM_OSS_IOCTL_SET_VOICE		0x22
99674e95caSDavid Howells #define SNDRV_DM_FM_OSS_IOCTL_SET_PARAMS	0x23
100674e95caSDavid Howells #define SNDRV_DM_FM_OSS_IOCTL_SET_MODE		0x24
101674e95caSDavid Howells #define SNDRV_DM_FM_OSS_IOCTL_SET_OPL		0x25
102674e95caSDavid Howells 
103674e95caSDavid Howells /*
104674e95caSDavid Howells  * Patch Record - fixed size for write
105674e95caSDavid Howells  */
106674e95caSDavid Howells 
107674e95caSDavid Howells #define FM_KEY_SBI	"SBI\032"
108674e95caSDavid Howells #define FM_KEY_2OP	"2OP\032"
109674e95caSDavid Howells #define FM_KEY_4OP	"4OP\032"
110674e95caSDavid Howells 
111674e95caSDavid Howells struct sbi_patch {
112674e95caSDavid Howells 	unsigned char prog;
113674e95caSDavid Howells 	unsigned char bank;
114674e95caSDavid Howells 	char key[4];
115674e95caSDavid Howells 	char name[25];
116674e95caSDavid Howells 	char extension[7];
117674e95caSDavid Howells 	unsigned char data[32];
118674e95caSDavid Howells };
119674e95caSDavid Howells 
120674e95caSDavid Howells #endif /* __SOUND_ASOUND_FM_H */
121