xref: /openbmc/linux/include/uapi/sound/asound_fm.h (revision 69ab6f5b)
1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 #ifndef __SOUND_ASOUND_FM_H
3 #define __SOUND_ASOUND_FM_H
4 
5 /*
6  *  Advanced Linux Sound Architecture - ALSA
7  *
8  *  Interface file between ALSA driver & user space
9  *  Copyright (c) 1994-98 by Jaroslav Kysela <perex@perex.cz>,
10  *                           4Front Technologies
11  *
12  *  Direct FM control
13  */
14 
15 #define SNDRV_DM_FM_MODE_OPL2	0x00
16 #define SNDRV_DM_FM_MODE_OPL3	0x01
17 
18 struct snd_dm_fm_info {
19 	unsigned char fm_mode;		/* OPL mode, see SNDRV_DM_FM_MODE_XXX */
20 	unsigned char rhythm;		/* percussion mode flag */
21 };
22 
23 /*
24  *  Data structure composing an FM "note" or sound event.
25  */
26 
27 struct snd_dm_fm_voice {
28 	unsigned char op;		/* operator cell (0 or 1) */
29 	unsigned char voice;		/* FM voice (0 to 17) */
30 
31 	unsigned char am;		/* amplitude modulation */
32 	unsigned char vibrato;		/* vibrato effect */
33 	unsigned char do_sustain;	/* sustain phase */
34 	unsigned char kbd_scale;	/* keyboard scaling */
35 	unsigned char harmonic;		/* 4 bits: harmonic and multiplier */
36 	unsigned char scale_level;	/* 2 bits: decrease output freq rises */
37 	unsigned char volume;		/* 6 bits: volume */
38 
39 	unsigned char attack;		/* 4 bits: attack rate */
40 	unsigned char decay;		/* 4 bits: decay rate */
41 	unsigned char sustain;		/* 4 bits: sustain level */
42 	unsigned char release;		/* 4 bits: release rate */
43 
44 	unsigned char feedback;		/* 3 bits: feedback for op0 */
45 	unsigned char connection;	/* 0 for serial, 1 for parallel */
46 	unsigned char left;		/* stereo left */
47 	unsigned char right;		/* stereo right */
48 	unsigned char waveform;		/* 3 bits: waveform shape */
49 };
50 
51 /*
52  *  This describes an FM note by its voice, octave, frequency number (10bit)
53  *  and key on/off.
54  */
55 
56 struct snd_dm_fm_note {
57 	unsigned char voice;	/* 0-17 voice channel */
58 	unsigned char octave;	/* 3 bits: what octave to play */
59 	unsigned int fnum;	/* 10 bits: frequency number */
60 	unsigned char key_on;	/* set for active, clear for silent */
61 };
62 
63 /*
64  *  FM parameters that apply globally to all voices, and thus are not "notes"
65  */
66 
67 struct snd_dm_fm_params {
68 	unsigned char am_depth;		/* amplitude modulation depth (1=hi) */
69 	unsigned char vib_depth;	/* vibrato depth (1=hi) */
70 	unsigned char kbd_split;	/* keyboard split */
71 	unsigned char rhythm;		/* percussion mode select */
72 
73 	/* This block is the percussion instrument data */
74 	unsigned char bass;
75 	unsigned char snare;
76 	unsigned char tomtom;
77 	unsigned char cymbal;
78 	unsigned char hihat;
79 };
80 
81 /*
82  *  FM mode ioctl settings
83  */
84 
85 #define SNDRV_DM_FM_IOCTL_INFO		_IOR('H', 0x20, struct snd_dm_fm_info)
86 #define SNDRV_DM_FM_IOCTL_RESET		_IO ('H', 0x21)
87 #define SNDRV_DM_FM_IOCTL_PLAY_NOTE	_IOW('H', 0x22, struct snd_dm_fm_note)
88 #define SNDRV_DM_FM_IOCTL_SET_VOICE	_IOW('H', 0x23, struct snd_dm_fm_voice)
89 #define SNDRV_DM_FM_IOCTL_SET_PARAMS	_IOW('H', 0x24, struct snd_dm_fm_params)
90 #define SNDRV_DM_FM_IOCTL_SET_MODE	_IOW('H', 0x25, int)
91 /* for OPL3 only */
92 #define SNDRV_DM_FM_IOCTL_SET_CONNECTION	_IOW('H', 0x26, int)
93 /* SBI patch management */
94 #define SNDRV_DM_FM_IOCTL_CLEAR_PATCHES	_IO ('H', 0x40)
95 
96 #define SNDRV_DM_FM_OSS_IOCTL_RESET		0x20
97 #define SNDRV_DM_FM_OSS_IOCTL_PLAY_NOTE		0x21
98 #define SNDRV_DM_FM_OSS_IOCTL_SET_VOICE		0x22
99 #define SNDRV_DM_FM_OSS_IOCTL_SET_PARAMS	0x23
100 #define SNDRV_DM_FM_OSS_IOCTL_SET_MODE		0x24
101 #define SNDRV_DM_FM_OSS_IOCTL_SET_OPL		0x25
102 
103 /*
104  * Patch Record - fixed size for write
105  */
106 
107 #define FM_KEY_SBI	"SBI\032"
108 #define FM_KEY_2OP	"2OP\032"
109 #define FM_KEY_4OP	"4OP\032"
110 
111 struct sbi_patch {
112 	unsigned char prog;
113 	unsigned char bank;
114 	char key[4];
115 	char name[25];
116 	char extension[7];
117 	unsigned char data[32];
118 };
119 
120 #endif /* __SOUND_ASOUND_FM_H */
121