1#ifndef __SOUND_EMUX_SYNTH_H
2#define __SOUND_EMUX_SYNTH_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <sound/seq_kernel.h>
25#include <sound/seq_device.h>
26#include <sound/soundfont.h>
27#include <sound/seq_midi_emul.h>
28#ifdef CONFIG_SND_SEQUENCER_OSS
29#include <sound/seq_oss.h>
30#endif
31#include <sound/emux_legacy.h>
32#include <sound/seq_virmidi.h>
33
34
35
36
37#define SNDRV_EMUX_USE_RAW_EFFECT
38
39struct snd_emux;
40struct snd_emux_port;
41struct snd_emux_voice;
42struct snd_emux_effect_table;
43
44
45
46
47struct snd_emux_operators {
48 struct module *owner;
49 struct snd_emux_voice *(*get_voice)(struct snd_emux *emu,
50 struct snd_emux_port *port);
51 int (*prepare)(struct snd_emux_voice *vp);
52 void (*trigger)(struct snd_emux_voice *vp);
53 void (*release)(struct snd_emux_voice *vp);
54 void (*update)(struct snd_emux_voice *vp, int update);
55 void (*terminate)(struct snd_emux_voice *vp);
56 void (*free_voice)(struct snd_emux_voice *vp);
57 void (*reset)(struct snd_emux *emu, int ch);
58
59 int (*sample_new)(struct snd_emux *emu, struct snd_sf_sample *sp,
60 struct snd_util_memhdr *hdr,
61 const void __user *data, long count);
62 int (*sample_free)(struct snd_emux *emu, struct snd_sf_sample *sp,
63 struct snd_util_memhdr *hdr);
64 void (*sample_reset)(struct snd_emux *emu);
65 int (*load_fx)(struct snd_emux *emu, int type, int arg,
66 const void __user *data, long count);
67 void (*sysex)(struct snd_emux *emu, char *buf, int len, int parsed,
68 struct snd_midi_channel_set *chset);
69#ifdef CONFIG_SND_SEQUENCER_OSS
70 int (*oss_ioctl)(struct snd_emux *emu, int cmd, int p1, int p2);
71#endif
72};
73
74
75
76
77
78#define SNDRV_EMUX_MAX_PORTS 32
79#define SNDRV_EMUX_MAX_VOICES 64
80#define SNDRV_EMUX_MAX_MULTI_VOICES 16
81
82
83
84
85
86
87#define SNDRV_EMUX_ACCEPT_ROM (1<<0)
88
89
90
91
92struct snd_emux {
93
94 struct snd_card *card;
95
96
97 int max_voices;
98 int mem_size;
99 int num_ports;
100 int pitch_shift;
101 struct snd_emux_operators ops;
102 void *hw;
103 unsigned long flags;
104 int midi_ports;
105 int midi_devidx;
106 unsigned int linear_panning: 1;
107 int hwdep_idx;
108 struct snd_hwdep *hwdep;
109
110
111 int num_voices;
112 struct snd_sf_list *sflist;
113 struct snd_emux_voice *voices;
114 int use_time;
115 spinlock_t voice_lock;
116 struct mutex register_mutex;
117 int client;
118 int ports[SNDRV_EMUX_MAX_PORTS];
119 struct snd_emux_port *portptrs[SNDRV_EMUX_MAX_PORTS];
120 int used;
121 char *name;
122 struct snd_rawmidi **vmidi;
123 struct timer_list tlist;
124 int timer_active;
125
126 struct snd_util_memhdr *memhdr;
127
128#ifdef CONFIG_SND_PROC_FS
129 struct snd_info_entry *proc;
130#endif
131
132#ifdef CONFIG_SND_SEQUENCER_OSS
133 struct snd_seq_device *oss_synth;
134#endif
135};
136
137
138
139
140
141struct snd_emux_port {
142
143 struct snd_midi_channel_set chset;
144 struct snd_emux *emu;
145
146 char port_mode;
147 int volume_atten;
148 unsigned long drum_flags;
149 int ctrls[EMUX_MD_END];
150#ifdef SNDRV_EMUX_USE_RAW_EFFECT
151 struct snd_emux_effect_table *effect;
152#endif
153#ifdef CONFIG_SND_SEQUENCER_OSS
154 struct snd_seq_oss_arg *oss_arg;
155#endif
156};
157
158
159#define SNDRV_EMUX_PORT_MODE_MIDI 0
160#define SNDRV_EMUX_PORT_MODE_OSS_SYNTH 1
161#define SNDRV_EMUX_PORT_MODE_OSS_MIDI 2
162
163
164
165
166struct snd_emux_voice {
167 int ch;
168
169 int state;
170#define SNDRV_EMUX_ST_OFF 0x00
171#define SNDRV_EMUX_ST_ON 0x01
172#define SNDRV_EMUX_ST_RELEASED (0x02|SNDRV_EMUX_ST_ON)
173#define SNDRV_EMUX_ST_SUSTAINED (0x04|SNDRV_EMUX_ST_ON)
174#define SNDRV_EMUX_ST_STANDBY (0x08|SNDRV_EMUX_ST_ON)
175#define SNDRV_EMUX_ST_PENDING (0x10|SNDRV_EMUX_ST_ON)
176#define SNDRV_EMUX_ST_LOCKED 0x100
177
178 unsigned int time;
179 unsigned char note;
180 unsigned char key;
181 unsigned char velocity;
182
183 struct snd_sf_zone *zone;
184 void *block;
185 struct snd_midi_channel *chan;
186 struct snd_emux_port *port;
187 struct snd_emux *emu;
188 void *hw;
189 unsigned long ontime;
190
191
192 struct soundfont_voice_info reg;
193
194
195 int avol;
196 int acutoff;
197 int apitch;
198 int apan;
199 int aaux;
200 int ptarget;
201 int vtarget;
202 int ftarget;
203
204};
205
206
207
208
209#define SNDRV_EMUX_UPDATE_VOLUME (1<<0)
210#define SNDRV_EMUX_UPDATE_PITCH (1<<1)
211#define SNDRV_EMUX_UPDATE_PAN (1<<2)
212#define SNDRV_EMUX_UPDATE_FMMOD (1<<3)
213#define SNDRV_EMUX_UPDATE_TREMFREQ (1<<4)
214#define SNDRV_EMUX_UPDATE_FM2FRQ2 (1<<5)
215#define SNDRV_EMUX_UPDATE_Q (1<<6)
216
217
218#ifdef SNDRV_EMUX_USE_RAW_EFFECT
219
220
221
222struct snd_emux_effect_table {
223
224 short val[EMUX_NUM_EFFECTS];
225 unsigned char flag[EMUX_NUM_EFFECTS];
226};
227#endif
228
229
230
231
232
233int snd_emux_new(struct snd_emux **remu);
234int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, char *name);
235int snd_emux_free(struct snd_emux *emu);
236
237
238
239
240void snd_emux_terminate_all(struct snd_emux *emu);
241void snd_emux_lock_voice(struct snd_emux *emu, int voice);
242void snd_emux_unlock_voice(struct snd_emux *emu, int voice);
243
244#endif
245