[PATCH] w1: Adds a sysfs entry (w1_master_search) that allows you to disable/enable...
[linux-2.6/verdex.git] / include / sound / emux_synth.h
blobc6970aac9bdcfdf0bb700a39a51b0031d16de471
1 #ifndef __SOUND_EMUX_SYNTH_H
2 #define __SOUND_EMUX_SYNTH_H
4 /*
5 * Defines for the Emu-series WaveTable chip
7 * Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "seq_kernel.h"
25 #include "seq_device.h"
26 #include "soundfont.h"
27 #include "seq_midi_emul.h"
28 #ifdef CONFIG_SND_SEQUENCER_OSS
29 #include "seq_oss.h"
30 #endif
31 #include "emux_legacy.h"
32 #include "seq_virmidi.h"
35 * compile flags
37 #define SNDRV_EMUX_USE_RAW_EFFECT
41 * typedefs
43 typedef struct snd_emux_effect_table snd_emux_effect_table_t;
44 typedef struct snd_emux_port snd_emux_port_t;
45 typedef struct snd_emux_voice snd_emux_voice_t;
46 typedef struct snd_emux snd_emux_t;
50 * operators
52 typedef struct snd_emux_operators {
53 struct module *owner;
54 snd_emux_voice_t *(*get_voice)(snd_emux_t *emu, snd_emux_port_t *port);
55 int (*prepare)(snd_emux_voice_t *vp);
56 void (*trigger)(snd_emux_voice_t *vp);
57 void (*release)(snd_emux_voice_t *vp);
58 void (*update)(snd_emux_voice_t *vp, int update);
59 void (*terminate)(snd_emux_voice_t *vp);
60 void (*free_voice)(snd_emux_voice_t *vp);
61 void (*reset)(snd_emux_t *emu, int ch);
62 /* the first parameters are snd_emux_t */
63 int (*sample_new)(snd_emux_t *emu, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr, const void __user *data, long count);
64 int (*sample_free)(snd_emux_t *emu, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr);
65 void (*sample_reset)(snd_emux_t *emu);
66 int (*load_fx)(snd_emux_t *emu, int type, int arg, const void __user *data, long count);
67 void (*sysex)(snd_emux_t *emu, char *buf, int len, int parsed, snd_midi_channel_set_t *chset);
68 #ifdef CONFIG_SND_SEQUENCER_OSS
69 int (*oss_ioctl)(snd_emux_t *emu, int cmd, int p1, int p2);
70 #endif
71 } snd_emux_operators_t;
75 * constant values
77 #define SNDRV_EMUX_MAX_PORTS 32 /* max # of sequencer ports */
78 #define SNDRV_EMUX_MAX_VOICES 64 /* max # of voices */
79 #define SNDRV_EMUX_MAX_MULTI_VOICES 16 /* max # of playable voices
80 * simultineously
84 * flags
86 #define SNDRV_EMUX_ACCEPT_ROM (1<<0)
89 * emuX wavetable
91 struct snd_emux {
93 snd_card_t *card; /* assigned card */
95 /* following should be initialized before registration */
96 int max_voices; /* Number of voices */
97 int mem_size; /* memory size (in byte) */
98 int num_ports; /* number of ports to be created */
99 int pitch_shift; /* pitch shift value (for Emu10k1) */
100 snd_emux_operators_t ops; /* operators */
101 void *hw; /* hardware */
102 unsigned long flags; /* other conditions */
103 int midi_ports; /* number of virtual midi devices */
104 int midi_devidx; /* device offset of virtual midi */
105 unsigned int linear_panning: 1; /* panning is linear (sbawe = 1, emu10k1 = 0) */
106 int hwdep_idx; /* hwdep device index */
107 snd_hwdep_t *hwdep; /* hwdep device */
109 /* private */
110 int num_voices; /* current number of voices */
111 snd_sf_list_t *sflist; /* root of SoundFont list */
112 snd_emux_voice_t *voices; /* Voices (EMU 'channel') */
113 int use_time; /* allocation counter */
114 spinlock_t voice_lock; /* Lock for voice access */
115 struct semaphore register_mutex;
116 int client; /* For the sequencer client */
117 int ports[SNDRV_EMUX_MAX_PORTS]; /* The ports for this device */
118 snd_emux_port_t *portptrs[SNDRV_EMUX_MAX_PORTS];
119 int used; /* use counter */
120 char *name; /* name of the device (internal) */
121 snd_rawmidi_t **vmidi;
122 struct timer_list tlist; /* for pending note-offs */
123 int timer_active;
125 snd_util_memhdr_t *memhdr; /* memory chunk information */
127 #ifdef CONFIG_PROC_FS
128 snd_info_entry_t *proc;
129 #endif
131 #ifdef CONFIG_SND_SEQUENCER_OSS
132 snd_seq_device_t *oss_synth;
133 #endif
138 * sequencer port information
140 struct snd_emux_port {
142 snd_midi_channel_set_t chset;
143 snd_emux_t *emu;
145 char port_mode; /* operation mode */
146 int volume_atten; /* emuX raw attenuation */
147 unsigned long drum_flags; /* drum bitmaps */
148 int ctrls[EMUX_MD_END]; /* control parameters */
149 #ifdef SNDRV_EMUX_USE_RAW_EFFECT
150 snd_emux_effect_table_t *effect;
151 #endif
152 #ifdef CONFIG_SND_SEQUENCER_OSS
153 snd_seq_oss_arg_t *oss_arg;
154 #endif
157 /* port_mode */
158 #define SNDRV_EMUX_PORT_MODE_MIDI 0 /* normal MIDI port */
159 #define SNDRV_EMUX_PORT_MODE_OSS_SYNTH 1 /* OSS synth port */
160 #define SNDRV_EMUX_PORT_MODE_OSS_MIDI 2 /* OSS multi channel synth port */
163 * A structure to keep track of each hardware voice
165 struct snd_emux_voice {
166 int ch; /* Hardware channel number */
168 int state; /* status */
169 #define SNDRV_EMUX_ST_OFF 0x00 /* Not playing, and inactive */
170 #define SNDRV_EMUX_ST_ON 0x01 /* Note on */
171 #define SNDRV_EMUX_ST_RELEASED (0x02|SNDRV_EMUX_ST_ON) /* Note released */
172 #define SNDRV_EMUX_ST_SUSTAINED (0x04|SNDRV_EMUX_ST_ON) /* Note sustained */
173 #define SNDRV_EMUX_ST_STANDBY (0x08|SNDRV_EMUX_ST_ON) /* Waiting to be triggered */
174 #define SNDRV_EMUX_ST_PENDING (0x10|SNDRV_EMUX_ST_ON) /* Note will be released */
175 #define SNDRV_EMUX_ST_LOCKED 0x100 /* Not accessible */
177 unsigned int time; /* An allocation time */
178 unsigned char note; /* Note currently assigned to this voice */
179 unsigned char key;
180 unsigned char velocity; /* Velocity of current note */
182 snd_sf_zone_t *zone; /* Zone assigned to this note */
183 void *block; /* sample block pointer (optional) */
184 snd_midi_channel_t *chan; /* Midi channel for this note */
185 snd_emux_port_t *port; /* associated port */
186 snd_emux_t *emu; /* assigned root info */
187 void *hw; /* hardware pointer (emu8000_t or emu10k1_t) */
188 unsigned long ontime; /* jiffies at note triggered */
190 /* Emu8k/Emu10k1 registers */
191 soundfont_voice_info_t reg;
193 /* additional registers */
194 int avol; /* volume attenuation */
195 int acutoff; /* cutoff target */
196 int apitch; /* pitch offset */
197 int apan; /* pan/aux pair */
198 int aaux;
199 int ptarget; /* pitch target */
200 int vtarget; /* volume target */
201 int ftarget; /* filter target */
206 * update flags (can be combined)
208 #define SNDRV_EMUX_UPDATE_VOLUME (1<<0)
209 #define SNDRV_EMUX_UPDATE_PITCH (1<<1)
210 #define SNDRV_EMUX_UPDATE_PAN (1<<2)
211 #define SNDRV_EMUX_UPDATE_FMMOD (1<<3)
212 #define SNDRV_EMUX_UPDATE_TREMFREQ (1<<4)
213 #define SNDRV_EMUX_UPDATE_FM2FRQ2 (1<<5)
214 #define SNDRV_EMUX_UPDATE_Q (1<<6)
217 #ifdef SNDRV_EMUX_USE_RAW_EFFECT
219 * effect table
221 struct snd_emux_effect_table {
222 /* Emu8000 specific effects */
223 short val[EMUX_NUM_EFFECTS];
224 unsigned char flag[EMUX_NUM_EFFECTS];
226 #endif /* SNDRV_EMUX_USE_RAW_EFFECT */
230 * prototypes - interface to Emu10k1 and Emu8k routines
232 int snd_emux_new(snd_emux_t **remu);
233 int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name);
234 int snd_emux_free(snd_emux_t *emu);
237 * exported functions
239 void snd_emux_terminate_all(snd_emux_t *emu);
240 void snd_emux_lock_voice(snd_emux_t *emu, int voice);
241 void snd_emux_unlock_voice(snd_emux_t *emu, int voice);
243 #endif /* __SOUND_EMUX_SYNTH_H */