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