blob: c2a4b967d5be9af90002ef0b3458e8759ae8c49b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __SOUND_ASOUND_FM_H
2#define __SOUND_ASOUND_FM_H
3
4/*
5 * Advanced Linux Sound Architecture - ALSA
6 *
7 * Interface file between ALSA driver & user space
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02008 * Copyright (c) 1994-98 by Jaroslav Kysela <perex@perex.cz>,
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 4Front Technologies
10 *
11 * Direct FM control
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 */
28
29#define SNDRV_DM_FM_MODE_OPL2 0x00
30#define SNDRV_DM_FM_MODE_OPL3 0x01
31
Takashi Iwai5b1646a2005-11-17 14:13:14 +010032struct snd_dm_fm_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 unsigned char fm_mode; /* OPL mode, see SNDRV_DM_FM_MODE_XXX */
34 unsigned char rhythm; /* percussion mode flag */
Takashi Iwai5b1646a2005-11-17 14:13:14 +010035};
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37/*
38 * Data structure composing an FM "note" or sound event.
39 */
40
Takashi Iwai5b1646a2005-11-17 14:13:14 +010041struct snd_dm_fm_voice {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 unsigned char op; /* operator cell (0 or 1) */
43 unsigned char voice; /* FM voice (0 to 17) */
44
45 unsigned char am; /* amplitude modulation */
46 unsigned char vibrato; /* vibrato effect */
47 unsigned char do_sustain; /* sustain phase */
48 unsigned char kbd_scale; /* keyboard scaling */
49 unsigned char harmonic; /* 4 bits: harmonic and multiplier */
50 unsigned char scale_level; /* 2 bits: decrease output freq rises */
51 unsigned char volume; /* 6 bits: volume */
52
53 unsigned char attack; /* 4 bits: attack rate */
54 unsigned char decay; /* 4 bits: decay rate */
55 unsigned char sustain; /* 4 bits: sustain level */
56 unsigned char release; /* 4 bits: release rate */
57
58 unsigned char feedback; /* 3 bits: feedback for op0 */
59 unsigned char connection; /* 0 for serial, 1 for parallel */
60 unsigned char left; /* stereo left */
61 unsigned char right; /* stereo right */
62 unsigned char waveform; /* 3 bits: waveform shape */
Takashi Iwai5b1646a2005-11-17 14:13:14 +010063};
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65/*
66 * This describes an FM note by its voice, octave, frequency number (10bit)
67 * and key on/off.
68 */
69
Takashi Iwai5b1646a2005-11-17 14:13:14 +010070struct snd_dm_fm_note {
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 unsigned char voice; /* 0-17 voice channel */
72 unsigned char octave; /* 3 bits: what octave to play */
73 unsigned int fnum; /* 10 bits: frequency number */
74 unsigned char key_on; /* set for active, clear for silent */
Takashi Iwai5b1646a2005-11-17 14:13:14 +010075};
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77/*
78 * FM parameters that apply globally to all voices, and thus are not "notes"
79 */
80
Takashi Iwai5b1646a2005-11-17 14:13:14 +010081struct snd_dm_fm_params {
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 unsigned char am_depth; /* amplitude modulation depth (1=hi) */
83 unsigned char vib_depth; /* vibrato depth (1=hi) */
84 unsigned char kbd_split; /* keyboard split */
85 unsigned char rhythm; /* percussion mode select */
86
87 /* This block is the percussion instrument data */
88 unsigned char bass;
89 unsigned char snare;
90 unsigned char tomtom;
91 unsigned char cymbal;
92 unsigned char hihat;
Takashi Iwai5b1646a2005-11-17 14:13:14 +010093};
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
95/*
96 * FM mode ioctl settings
97 */
98
Takashi Iwai5b1646a2005-11-17 14:13:14 +010099#define SNDRV_DM_FM_IOCTL_INFO _IOR('H', 0x20, struct snd_dm_fm_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100#define SNDRV_DM_FM_IOCTL_RESET _IO ('H', 0x21)
Takashi Iwai5b1646a2005-11-17 14:13:14 +0100101#define SNDRV_DM_FM_IOCTL_PLAY_NOTE _IOW('H', 0x22, struct snd_dm_fm_note)
102#define SNDRV_DM_FM_IOCTL_SET_VOICE _IOW('H', 0x23, struct snd_dm_fm_voice)
103#define SNDRV_DM_FM_IOCTL_SET_PARAMS _IOW('H', 0x24, struct snd_dm_fm_params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#define SNDRV_DM_FM_IOCTL_SET_MODE _IOW('H', 0x25, int)
105/* for OPL3 only */
106#define SNDRV_DM_FM_IOCTL_SET_CONNECTION _IOW('H', 0x26, int)
Takashi Iwai224a0332007-10-30 11:49:22 +0100107/* SBI patch management */
108#define SNDRV_DM_FM_IOCTL_CLEAR_PATCHES _IO ('H', 0x40)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
110#define SNDRV_DM_FM_OSS_IOCTL_RESET 0x20
111#define SNDRV_DM_FM_OSS_IOCTL_PLAY_NOTE 0x21
112#define SNDRV_DM_FM_OSS_IOCTL_SET_VOICE 0x22
113#define SNDRV_DM_FM_OSS_IOCTL_SET_PARAMS 0x23
114#define SNDRV_DM_FM_OSS_IOCTL_SET_MODE 0x24
115#define SNDRV_DM_FM_OSS_IOCTL_SET_OPL 0x25
116
Takashi Iwai224a0332007-10-30 11:49:22 +0100117/*
118 * Patch Record - fixed size for write
119 */
120
121#define FM_KEY_SBI "SBI\032"
122#define FM_KEY_2OP "2OP\032"
123#define FM_KEY_4OP "4OP\032"
124
125struct sbi_patch {
126 unsigned char prog;
127 unsigned char bank;
128 char key[4];
129 char name[25];
130 char extension[7];
131 unsigned char data[32];
132};
133
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134#endif /* __SOUND_ASOUND_FM_H */