1#ifndef __SOUND_OPL3_H
2#define __SOUND_OPL3_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54#include "driver.h"
55#include <linux/time.h>
56#include <linux/mutex.h>
57#include "core.h"
58#include "hwdep.h"
59#include "timer.h"
60#include "seq_midi_emul.h"
61#ifdef CONFIG_SND_SEQUENCER_OSS
62#include "seq_oss.h"
63#include "seq_oss_legacy.h"
64#endif
65#include "seq_device.h"
66#include "ainstr_fm.h"
67
68
69
70
71
72#define OPL3_REG_TEST 0x01
73#define OPL3_ENABLE_WAVE_SELECT 0x20
74
75#define OPL3_REG_TIMER1 0x02
76#define OPL3_REG_TIMER2 0x03
77#define OPL3_REG_TIMER_CONTROL 0x04
78#define OPL3_IRQ_RESET 0x80
79#define OPL3_TIMER1_MASK 0x40
80#define OPL3_TIMER2_MASK 0x20
81#define OPL3_TIMER1_START 0x01
82#define OPL3_TIMER2_START 0x02
83
84#define OPL3_REG_CONNECTION_SELECT 0x04
85#define OPL3_LEFT_4OP_0 0x01
86#define OPL3_LEFT_4OP_1 0x02
87#define OPL3_LEFT_4OP_2 0x04
88#define OPL3_RIGHT_4OP_0 0x08
89#define OPL3_RIGHT_4OP_1 0x10
90#define OPL3_RIGHT_4OP_2 0x20
91
92#define OPL3_REG_MODE 0x05
93#define OPL3_OPL3_ENABLE 0x01
94#define OPL3_OPL4_ENABLE 0x02
95
96#define OPL3_REG_KBD_SPLIT 0x08
97#define OPL3_COMPOSITE_SINE_WAVE_MODE 0x80
98#define OPL3_KEYBOARD_SPLIT 0x40
99
100#define OPL3_REG_PERCUSSION 0xbd
101#define OPL3_TREMOLO_DEPTH 0x80
102#define OPL3_VIBRATO_DEPTH 0x40
103#define OPL3_PERCUSSION_ENABLE 0x20
104#define OPL3_BASSDRUM_ON 0x10
105#define OPL3_SNAREDRUM_ON 0x08
106#define OPL3_TOMTOM_ON 0x04
107#define OPL3_CYMBAL_ON 0x02
108#define OPL3_HIHAT_ON 0x01
109
110
111
112
113
114
115
116#define OPL3_REG_AM_VIB 0x20
117#define OPL3_TREMOLO_ON 0x80
118#define OPL3_VIBRATO_ON 0x40
119#define OPL3_SUSTAIN_ON 0x20
120#define OPL3_KSR 0x10
121#define OPL3_MULTIPLE_MASK 0x0f
122
123
124
125
126#define OPL3_REG_KSL_LEVEL 0x40
127#define OPL3_KSL_MASK 0xc0
128#define OPL3_TOTAL_LEVEL_MASK 0x3f
129
130
131
132
133#define OPL3_REG_ATTACK_DECAY 0x60
134#define OPL3_ATTACK_MASK 0xf0
135#define OPL3_DECAY_MASK 0x0f
136
137
138
139
140#define OPL3_REG_SUSTAIN_RELEASE 0x80
141#define OPL3_SUSTAIN_MASK 0xf0
142#define OPL3_RELEASE_MASK 0x0f
143
144
145
146
147#define OPL3_REG_WAVE_SELECT 0xe0
148#define OPL3_WAVE_SELECT_MASK 0x07
149
150
151
152
153
154
155
156#define OPL3_REG_FNUM_LOW 0xa0
157
158
159
160
161#define OPL3_REG_KEYON_BLOCK 0xb0
162#define OPL3_KEYON_BIT 0x20
163#define OPL3_BLOCKNUM_MASK 0x1c
164#define OPL3_FNUM_HIGH_MASK 0x03
165
166
167
168
169
170
171
172
173
174
175
176
177
178#define OPL3_REG_FEEDBACK_CONNECTION 0xc0
179#define OPL3_FEEDBACK_MASK 0x0e
180#define OPL3_CONNECTION_BIT 0x01
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215#define OPL3_STEREO_BITS 0x30
216#define OPL3_VOICE_TO_LEFT 0x10
217#define OPL3_VOICE_TO_RIGHT 0x20
218
219
220
221
222
223#define OPL3_LEFT 0x0000
224#define OPL3_RIGHT 0x0100
225
226#define OPL3_HW_AUTO 0x0000
227#define OPL3_HW_OPL2 0x0200
228#define OPL3_HW_OPL3 0x0300
229#define OPL3_HW_OPL3_SV 0x0301
230#define OPL3_HW_OPL3_CS 0x0302
231#define OPL3_HW_OPL3_FM801 0x0303
232#define OPL3_HW_OPL3_CS4281 0x0304
233#define OPL3_HW_OPL4 0x0400
234#define OPL3_HW_OPL4_ML 0x0401
235#define OPL3_HW_MASK 0xff00
236
237#define MAX_OPL2_VOICES 9
238#define MAX_OPL3_VOICES 18
239
240struct snd_opl3;
241
242
243
244
245struct snd_opl3_voice {
246 int state;
247#define SNDRV_OPL3_ST_OFF 0
248#define SNDRV_OPL3_ST_ON_2OP 1
249#define SNDRV_OPL3_ST_ON_4OP 2
250#define SNDRV_OPL3_ST_NOT_AVAIL -1
251
252 unsigned int time;
253 unsigned char note;
254
255 unsigned long note_off;
256 int note_off_check;
257
258 unsigned char keyon_reg;
259
260 struct snd_midi_channel *chan;
261};
262
263struct snd_opl3 {
264 unsigned long l_port;
265 unsigned long r_port;
266 struct resource *res_l_port;
267 struct resource *res_r_port;
268 unsigned short hardware;
269
270 void (*command) (struct snd_opl3 * opl3, unsigned short cmd, unsigned char val);
271 unsigned short timer_enable;
272 int seq_dev_num;
273 struct snd_timer *timer1;
274 struct snd_timer *timer2;
275 spinlock_t timer_lock;
276
277 void *private_data;
278 void (*private_free)(struct snd_opl3 *);
279
280 spinlock_t reg_lock;
281 struct snd_card *card;
282 int used;
283 unsigned char fm_mode;
284 unsigned char rhythm;
285 unsigned char max_voices;
286#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
287#define SNDRV_OPL3_MODE_SYNTH 0
288#define SNDRV_OPL3_MODE_SEQ 1
289 int synth_mode;
290 int seq_client;
291
292 struct snd_seq_device *seq_dev;
293 struct snd_midi_channel_set * chset;
294
295#ifdef CONFIG_SND_SEQUENCER_OSS
296 struct snd_seq_device *oss_seq_dev;
297 struct snd_midi_channel_set * oss_chset;
298#endif
299
300 struct snd_seq_kinstr_ops fm_ops;
301 struct snd_seq_kinstr_list *ilist;
302
303 struct snd_opl3_voice voices[MAX_OPL3_VOICES];
304 int use_time;
305
306 unsigned short connection_reg;
307 unsigned char drum_reg;
308
309 spinlock_t voice_lock;
310
311 struct timer_list tlist;
312 int sys_timer_status;
313 spinlock_t sys_timer_lock;
314#endif
315 struct mutex access_mutex;
316};
317
318
319void snd_opl3_interrupt(struct snd_hwdep * hw);
320int snd_opl3_new(struct snd_card *card, unsigned short hardware,
321 struct snd_opl3 **ropl3);
322int snd_opl3_init(struct snd_opl3 *opl3);
323int snd_opl3_create(struct snd_card *card,
324 unsigned long l_port, unsigned long r_port,
325 unsigned short hardware,
326 int integrated,
327 struct snd_opl3 ** opl3);
328int snd_opl3_timer_new(struct snd_opl3 * opl3, int timer1_dev, int timer2_dev);
329int snd_opl3_hwdep_new(struct snd_opl3 * opl3, int device, int seq_device,
330 struct snd_hwdep ** rhwdep);
331
332
333int snd_opl3_open(struct snd_hwdep * hw, struct file *file);
334int snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file,
335 unsigned int cmd, unsigned long arg);
336int snd_opl3_release(struct snd_hwdep * hw, struct file *file);
337
338void snd_opl3_reset(struct snd_opl3 * opl3);
339
340#endif
341