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 *   This program is free software; you can redistribute it and/or modify
15 *   it under the terms of the GNU General Public License as published by
16 *   the Free Software Foundation; either version 2 of the License, or
17 *   (at your option) any later version.
18 *
19 *   This program is distributed in the hope that it will be useful,
20 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
21 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 *   GNU General Public License for more details.
23 *
24 *   You should have received a copy of the GNU General Public License
25 *   along with this program; if not, write to the Free Software
26 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
27 *
28 */
29
30#define SNDRV_DM_FM_MODE_OPL2	0x00
31#define SNDRV_DM_FM_MODE_OPL3	0x01
32
33struct snd_dm_fm_info {
34	unsigned char fm_mode;		/* OPL mode, see SNDRV_DM_FM_MODE_XXX */
35	unsigned char rhythm;		/* percussion mode flag */
36};
37
38/*
39 *  Data structure composing an FM "note" or sound event.
40 */
41
42struct snd_dm_fm_voice {
43	unsigned char op;		/* operator cell (0 or 1) */
44	unsigned char voice;		/* FM voice (0 to 17) */
45
46	unsigned char am;		/* amplitude modulation */
47	unsigned char vibrato;		/* vibrato effect */
48	unsigned char do_sustain;	/* sustain phase */
49	unsigned char kbd_scale;	/* keyboard scaling */
50	unsigned char harmonic;		/* 4 bits: harmonic and multiplier */
51	unsigned char scale_level;	/* 2 bits: decrease output freq rises */
52	unsigned char volume;		/* 6 bits: volume */
53
54	unsigned char attack;		/* 4 bits: attack rate */
55	unsigned char decay;		/* 4 bits: decay rate */
56	unsigned char sustain;		/* 4 bits: sustain level */
57	unsigned char release;		/* 4 bits: release rate */
58
59	unsigned char feedback;		/* 3 bits: feedback for op0 */
60	unsigned char connection;	/* 0 for serial, 1 for parallel */
61	unsigned char left;		/* stereo left */
62	unsigned char right;		/* stereo right */
63	unsigned char waveform;		/* 3 bits: waveform shape */
64};
65
66/*
67 *  This describes an FM note by its voice, octave, frequency number (10bit)
68 *  and key on/off.
69 */
70
71struct snd_dm_fm_note {
72	unsigned char voice;	/* 0-17 voice channel */
73	unsigned char octave;	/* 3 bits: what octave to play */
74	unsigned int fnum;	/* 10 bits: frequency number */
75	unsigned char key_on;	/* set for active, clear for silent */
76};
77
78/*
79 *  FM parameters that apply globally to all voices, and thus are not "notes"
80 */
81
82struct snd_dm_fm_params {
83	unsigned char am_depth;		/* amplitude modulation depth (1=hi) */
84	unsigned char vib_depth;	/* vibrato depth (1=hi) */
85	unsigned char kbd_split;	/* keyboard split */
86	unsigned char rhythm;		/* percussion mode select */
87
88	/* This block is the percussion instrument data */
89	unsigned char bass;
90	unsigned char snare;
91	unsigned char tomtom;
92	unsigned char cymbal;
93	unsigned char hihat;
94};
95
96/*
97 *  FM mode ioctl settings
98 */
99
100#define SNDRV_DM_FM_IOCTL_INFO		_IOR('H', 0x20, struct snd_dm_fm_info)
101#define SNDRV_DM_FM_IOCTL_RESET		_IO ('H', 0x21)
102#define SNDRV_DM_FM_IOCTL_PLAY_NOTE	_IOW('H', 0x22, struct snd_dm_fm_note)
103#define SNDRV_DM_FM_IOCTL_SET_VOICE	_IOW('H', 0x23, struct snd_dm_fm_voice)
104#define SNDRV_DM_FM_IOCTL_SET_PARAMS	_IOW('H', 0x24, struct snd_dm_fm_params)
105#define SNDRV_DM_FM_IOCTL_SET_MODE	_IOW('H', 0x25, int)
106/* for OPL3 only */
107#define SNDRV_DM_FM_IOCTL_SET_CONNECTION	_IOW('H', 0x26, int)
108/* SBI patch management */
109#define SNDRV_DM_FM_IOCTL_CLEAR_PATCHES	_IO ('H', 0x40)
110
111#define SNDRV_DM_FM_OSS_IOCTL_RESET		0x20
112#define SNDRV_DM_FM_OSS_IOCTL_PLAY_NOTE		0x21
113#define SNDRV_DM_FM_OSS_IOCTL_SET_VOICE		0x22
114#define SNDRV_DM_FM_OSS_IOCTL_SET_PARAMS	0x23
115#define SNDRV_DM_FM_OSS_IOCTL_SET_MODE		0x24
116#define SNDRV_DM_FM_OSS_IOCTL_SET_OPL		0x25
117
118/*
119 * Patch Record - fixed size for write
120 */
121
122#define FM_KEY_SBI	"SBI\032"
123#define FM_KEY_2OP	"2OP\032"
124#define FM_KEY_4OP	"4OP\032"
125
126struct sbi_patch {
127	unsigned char prog;
128	unsigned char bank;
129	char key[4];
130	char name[25];
131	char extension[7];
132	unsigned char data[32];
133};
134
135#endif /* __SOUND_ASOUND_FM_H */
136