diff options
Diffstat (limited to 'sound/drivers/opl3/opl3_midi.c')
-rw-r--r-- | sound/drivers/opl3/opl3_midi.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c index 3557b6e20eb5..cebcb8b78acb 100644 --- a/sound/drivers/opl3/opl3_midi.c +++ b/sound/drivers/opl3/opl3_midi.c | |||
@@ -289,8 +289,6 @@ static int snd_opl3_oss_map[MAX_OPL3_VOICES] = { | |||
289 | void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) | 289 | void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) |
290 | { | 290 | { |
291 | struct snd_opl3 *opl3; | 291 | struct snd_opl3 *opl3; |
292 | struct snd_seq_instr wanted; | ||
293 | struct snd_seq_kinstr *kinstr; | ||
294 | int instr_4op; | 292 | int instr_4op; |
295 | 293 | ||
296 | int voice; | 294 | int voice; |
@@ -306,11 +304,13 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) | |||
306 | unsigned char voice_offset; | 304 | unsigned char voice_offset; |
307 | unsigned short opl3_reg; | 305 | unsigned short opl3_reg; |
308 | unsigned char reg_val; | 306 | unsigned char reg_val; |
307 | unsigned char prg, bank; | ||
309 | 308 | ||
310 | int key = note; | 309 | int key = note; |
311 | unsigned char fnum, blocknum; | 310 | unsigned char fnum, blocknum; |
312 | int i; | 311 | int i; |
313 | 312 | ||
313 | struct fm_patch *patch; | ||
314 | struct fm_instrument *fm; | 314 | struct fm_instrument *fm; |
315 | unsigned long flags; | 315 | unsigned long flags; |
316 | 316 | ||
@@ -320,19 +320,17 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) | |||
320 | snd_printk("Note on, ch %i, inst %i, note %i, vel %i\n", | 320 | snd_printk("Note on, ch %i, inst %i, note %i, vel %i\n", |
321 | chan->number, chan->midi_program, note, vel); | 321 | chan->number, chan->midi_program, note, vel); |
322 | #endif | 322 | #endif |
323 | wanted.cluster = 0; | ||
324 | wanted.std = SNDRV_SEQ_INSTR_TYPE2_OPL2_3; | ||
325 | 323 | ||
326 | /* in SYNTH mode, application takes care of voices */ | 324 | /* in SYNTH mode, application takes care of voices */ |
327 | /* in SEQ mode, drum voice numbers are notes on drum channel */ | 325 | /* in SEQ mode, drum voice numbers are notes on drum channel */ |
328 | if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) { | 326 | if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) { |
329 | if (chan->drum_channel) { | 327 | if (chan->drum_channel) { |
330 | /* percussion instruments are located in bank 128 */ | 328 | /* percussion instruments are located in bank 128 */ |
331 | wanted.bank = 128; | 329 | bank = 128; |
332 | wanted.prg = note; | 330 | prg = note; |
333 | } else { | 331 | } else { |
334 | wanted.bank = chan->gm_bank_select; | 332 | bank = chan->gm_bank_select; |
335 | wanted.prg = chan->midi_program; | 333 | prg = chan->midi_program; |
336 | } | 334 | } |
337 | } else { | 335 | } else { |
338 | /* Prepare for OSS mode */ | 336 | /* Prepare for OSS mode */ |
@@ -340,8 +338,8 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) | |||
340 | return; | 338 | return; |
341 | 339 | ||
342 | /* OSS instruments are located in bank 127 */ | 340 | /* OSS instruments are located in bank 127 */ |
343 | wanted.bank = 127; | 341 | bank = 127; |
344 | wanted.prg = chan->midi_program; | 342 | prg = chan->midi_program; |
345 | } | 343 | } |
346 | 344 | ||
347 | spin_lock_irqsave(&opl3->voice_lock, flags); | 345 | spin_lock_irqsave(&opl3->voice_lock, flags); |
@@ -353,15 +351,14 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) | |||
353 | } | 351 | } |
354 | 352 | ||
355 | __extra_prg: | 353 | __extra_prg: |
356 | kinstr = snd_seq_instr_find(opl3->ilist, &wanted, 1, 0); | 354 | patch = snd_opl3_find_patch(opl3, prg, bank, 0); |
357 | if (kinstr == NULL) { | 355 | if (!patch) { |
358 | spin_unlock_irqrestore(&opl3->voice_lock, flags); | 356 | spin_unlock_irqrestore(&opl3->voice_lock, flags); |
359 | return; | 357 | return; |
360 | } | 358 | } |
361 | 359 | ||
362 | fm = KINSTR_DATA(kinstr); | 360 | fm = &patch->inst; |
363 | 361 | switch (patch->type) { | |
364 | switch (fm->type) { | ||
365 | case FM_PATCH_OPL2: | 362 | case FM_PATCH_OPL2: |
366 | instr_4op = 0; | 363 | instr_4op = 0; |
367 | break; | 364 | break; |
@@ -371,14 +368,12 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) | |||
371 | break; | 368 | break; |
372 | } | 369 | } |
373 | default: | 370 | default: |
374 | snd_seq_instr_free_use(opl3->ilist, kinstr); | ||
375 | spin_unlock_irqrestore(&opl3->voice_lock, flags); | 371 | spin_unlock_irqrestore(&opl3->voice_lock, flags); |
376 | return; | 372 | return; |
377 | } | 373 | } |
378 | |||
379 | #ifdef DEBUG_MIDI | 374 | #ifdef DEBUG_MIDI |
380 | snd_printk(" --> OPL%i instrument: %s\n", | 375 | snd_printk(" --> OPL%i instrument: %s\n", |
381 | instr_4op ? 3 : 2, kinstr->name); | 376 | instr_4op ? 3 : 2, patch->name); |
382 | #endif | 377 | #endif |
383 | /* in SYNTH mode, application takes care of voices */ | 378 | /* in SYNTH mode, application takes care of voices */ |
384 | /* in SEQ mode, allocate voice on free OPL3 channel */ | 379 | /* in SEQ mode, allocate voice on free OPL3 channel */ |
@@ -569,8 +564,6 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) | |||
569 | /* get extra pgm, but avoid possible loops */ | 564 | /* get extra pgm, but avoid possible loops */ |
570 | extra_prg = (extra_prg) ? 0 : fm->modes; | 565 | extra_prg = (extra_prg) ? 0 : fm->modes; |
571 | 566 | ||
572 | snd_seq_instr_free_use(opl3->ilist, kinstr); | ||
573 | |||
574 | /* do the bookkeeping */ | 567 | /* do the bookkeeping */ |
575 | vp->time = opl3->use_time++; | 568 | vp->time = opl3->use_time++; |
576 | vp->note = key; | 569 | vp->note = key; |
@@ -601,12 +594,12 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) | |||
601 | /* allocate extra program if specified in patch library */ | 594 | /* allocate extra program if specified in patch library */ |
602 | if (extra_prg) { | 595 | if (extra_prg) { |
603 | if (extra_prg > 128) { | 596 | if (extra_prg > 128) { |
604 | wanted.bank = 128; | 597 | bank = 128; |
605 | /* percussions start at 35 */ | 598 | /* percussions start at 35 */ |
606 | wanted.prg = extra_prg - 128 + 35 - 1; | 599 | prg = extra_prg - 128 + 35 - 1; |
607 | } else { | 600 | } else { |
608 | wanted.bank = 0; | 601 | bank = 0; |
609 | wanted.prg = extra_prg - 1; | 602 | prg = extra_prg - 1; |
610 | } | 603 | } |
611 | #ifdef DEBUG_MIDI | 604 | #ifdef DEBUG_MIDI |
612 | snd_printk(" *** allocating extra program\n"); | 605 | snd_printk(" *** allocating extra program\n"); |