22 #include <linux/slab.h>
23 #include <linux/export.h>
27 #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
28 #define OPL3_SUPPORT_SYNTH
54 { 0x00, 0x03, 0x08, 0x0b },
55 { 0x01, 0x04, 0x09, 0x0c },
56 { 0x02, 0x05, 0x0a, 0x0d },
58 { 0x08, 0x0b, 0x00, 0x00 },
59 { 0x09, 0x0c, 0x00, 0x00 },
60 { 0x0a, 0x0d, 0x00, 0x00 },
62 { 0x10, 0x13, 0x00, 0x00 },
63 { 0x11, 0x14, 0x00, 0x00 },
64 { 0x12, 0x15, 0x00, 0x00 }
75 static int snd_opl3_set_mode(
struct snd_opl3 * opl3,
int mode);
92 unsigned int cmd,
unsigned long arg)
114 #ifdef CONFIG_SND_OSSEMUL
121 #ifdef CONFIG_SND_OSSEMUL
128 return snd_opl3_play_note(opl3, ¬e);
132 #ifdef CONFIG_SND_OSSEMUL
139 return snd_opl3_set_voice(opl3, &voice);
143 #ifdef CONFIG_SND_OSSEMUL
150 return snd_opl3_set_params(opl3, ¶ms);
154 #ifdef CONFIG_SND_OSSEMUL
157 return snd_opl3_set_mode(opl3, (
int) arg);
160 #ifdef CONFIG_SND_OSSEMUL
163 return snd_opl3_set_connection(opl3, (
int) arg);
165 #ifdef OPL3_SUPPORT_SYNTH
167 snd_opl3_clear_patches(opl3);
171 #ifdef CONFIG_SND_DEBUG
190 #ifdef OPL3_SUPPORT_SYNTH
202 while (count >=
sizeof(inst)) {
213 err = snd_opl3_load_patch(opl3, inst.prog, inst.bank, type,
214 inst.name, inst.extension,
218 result +=
sizeof(inst);
219 count -=
sizeof(inst);
221 return result > 0 ? result :
err;
232 #define ATTACK_DECAY 4
233 #define SUSTAIN_RELEASE 6
234 #define WAVE_SELECT 8
237 #define CONNECTION 10
238 #define OFFSET_4OP 11
251 int snd_opl3_load_patch(
struct snd_opl3 *opl3,
254 const unsigned char *
ext,
255 const unsigned char *
data)
260 patch = snd_opl3_find_patch(opl3, prog, bank, 1);
266 for (i = 0; i < 2; i++) {
273 patch->
inst.feedback_connection[0] = data[CONNECTION];
276 for (i = 0; i < 2; i++) {
277 patch->
inst.op[i+2].am_vib =
279 patch->
inst.op[i+2].ksl_level =
281 patch->
inst.op[i+2].attack_decay =
283 patch->
inst.op[i+2].sustain_release =
285 patch->
inst.op[i+2].wave_select =
288 patch->
inst.feedback_connection[1] =
289 data[OFFSET_4OP + CONNECTION];
293 patch->
inst.echo_delay = ext[0];
294 patch->
inst.echo_atten = ext[1];
295 patch->
inst.chorus_spread = ext[2];
296 patch->
inst.trnsps = ext[3];
297 patch->
inst.fix_dur = ext[4];
298 patch->
inst.modes = ext[5];
299 patch->
inst.fix_key = ext[6];
314 struct fm_patch *snd_opl3_find_patch(
struct snd_opl3 *opl3,
int prog,
int bank,
318 unsigned int key = (prog +
bank) % OPL3_PATCH_HASH_SIZE;
321 for (patch = opl3->patch_table[key]; patch; patch = patch->
next) {
322 if (patch->
prog == prog && patch->
bank == bank)
333 patch->
next = opl3->patch_table[
key];
334 opl3->patch_table[
key] = patch;
342 void snd_opl3_clear_patches(
struct snd_opl3 *opl3)
345 for (i = 0; i < OPL3_PATCH_HASH_SIZE; i++) {
347 for (patch = opl3->patch_table[i]; patch; patch = next) {
352 memset(opl3->patch_table, 0,
sizeof(opl3->patch_table));
360 unsigned short opl3_reg;
362 unsigned short reg_side;
363 unsigned char voice_offset;
370 for (i = 0; i < max_voices; i++) {
387 opl3->
command(opl3, opl3_reg, 0x00);
402 unsigned short reg_side;
403 unsigned char voice_offset;
405 unsigned short opl3_reg;
415 if (note->
voice < MAX_OPL2_VOICES) {
418 voice_offset = note->
voice;
426 reg_val = (
unsigned char) note->
fnum;
428 opl3->
command(opl3, opl3_reg, reg_val);
441 opl3->
command(opl3, opl3_reg, reg_val);
449 unsigned short reg_side;
450 unsigned char op_offset;
451 unsigned char voice_offset;
453 unsigned short opl3_reg;
466 if (voice->
voice < MAX_OPL2_VOICES) {
469 voice_offset = voice->
voice;
496 opl3->
command(opl3, opl3_reg, reg_val);
505 opl3->
command(opl3, opl3_reg, reg_val);
514 opl3->
command(opl3, opl3_reg, reg_val);
523 opl3->
command(opl3, opl3_reg, reg_val);
539 opl3->
command(opl3, opl3_reg, reg_val);
544 opl3->
command(opl3, opl3_reg, reg_val);
589 static int snd_opl3_set_mode(
struct snd_opl3 * opl3,
int mode)