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