diff options
Diffstat (limited to 'sound/isa/gus')
-rw-r--r-- | sound/isa/gus/Makefile | 12 | ||||
-rw-r--r-- | sound/isa/gus/gus_main.c | 23 | ||||
-rw-r--r-- | sound/isa/gus/gus_sample.c | 165 | ||||
-rw-r--r-- | sound/isa/gus/gus_simple.c | 634 | ||||
-rw-r--r-- | sound/isa/gus/gus_synth.c | 314 |
5 files changed, 0 insertions, 1148 deletions
diff --git a/sound/isa/gus/Makefile b/sound/isa/gus/Makefile index df3d59f25f5e..6cd4ee03754a 100644 --- a/sound/isa/gus/Makefile +++ b/sound/isa/gus/Makefile @@ -9,7 +9,6 @@ snd-gus-lib-objs := gus_main.o \ gus_pcm.o gus_mixer.o \ gus_uart.o \ gus_reset.o -snd-gus-synth-objs := gus_synth.o gus_sample.o gus_simple.o gus_instr.o snd-gusclassic-objs := gusclassic.o snd-gusextreme-objs := gusextreme.o @@ -17,20 +16,9 @@ snd-gusmax-objs := gusmax.o snd-interwave-objs := interwave.o snd-interwave-stb-objs := interwave-stb.o -# -# this function returns: -# "m" - CONFIG_SND_SEQUENCER is m -# <empty string> - CONFIG_SND_SEQUENCER is undefined -# otherwise parameter #1 value -# -sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1))) - # Toplevel Module Dependency obj-$(CONFIG_SND_GUSCLASSIC) += snd-gusclassic.o snd-gus-lib.o obj-$(CONFIG_SND_GUSMAX) += snd-gusmax.o snd-gus-lib.o obj-$(CONFIG_SND_GUSEXTREME) += snd-gusextreme.o snd-gus-lib.o obj-$(CONFIG_SND_INTERWAVE) += snd-interwave.o snd-gus-lib.o obj-$(CONFIG_SND_INTERWAVE_STB) += snd-interwave-stb.o snd-gus-lib.o -obj-$(call sequencer,$(CONFIG_SND_GUS_SYNTH)) += snd-gus-synth.o - -obj-m := $(sort $(obj-m)) diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index b14d5d6d9a32..e4453e5e5c23 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -104,12 +104,6 @@ static int snd_gus_free(struct snd_gus_card *gus) { if (gus->gf1.res_port2 == NULL) goto __hw_end; -#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) - if (gus->seq_dev) { - snd_device_free(gus->card, gus->seq_dev); - gus->seq_dev = NULL; - } -#endif snd_gf1_stop(gus); snd_gus_init_dma_irq(gus, 0); __hw_end: @@ -408,14 +402,6 @@ static int snd_gus_check_version(struct snd_gus_card * gus) return 0; } -#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) -static void snd_gus_seq_dev_free(struct snd_seq_device *seq_dev) -{ - struct snd_gus_card *gus = seq_dev->private_data; - gus->seq_dev = NULL; -} -#endif - int snd_gus_initialize(struct snd_gus_card *gus) { int err; @@ -430,15 +416,6 @@ int snd_gus_initialize(struct snd_gus_card *gus) } if ((err = snd_gus_init_dma_irq(gus, 1)) < 0) return err; -#if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) - if (snd_seq_device_new(gus->card, 1, SNDRV_SEQ_DEV_ID_GUS, - sizeof(struct snd_gus_card *), &gus->seq_dev) >= 0) { - strcpy(gus->seq_dev->name, "GUS"); - *(struct snd_gus_card **)SNDRV_SEQ_DEVICE_ARGPTR(gus->seq_dev) = gus; - gus->seq_dev->private_data = gus; - gus->seq_dev->private_free = snd_gus_seq_dev_free; - } -#endif snd_gf1_start(gus); gus->initialized = 1; return 0; diff --git a/sound/isa/gus/gus_sample.c b/sound/isa/gus/gus_sample.c deleted file mode 100644 index cba0829a7106..000000000000 --- a/sound/isa/gus/gus_sample.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Routines for Gravis UltraSound soundcards - Sample support - * Copyright (c) by Jaroslav Kysela <perex@perex.cz> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include <sound/driver.h> -#include <linux/time.h> -#include <sound/core.h> -#include <sound/gus.h> - -/* - * - */ - -static void select_instrument(struct snd_gus_card * gus, struct snd_gus_voice * v) -{ - struct snd_seq_kinstr *instr; - -#if 0 - printk("select instrument: cluster = %li, std = 0x%x, bank = %i, prg = %i\n", - v->instr.cluster, - v->instr.std, - v->instr.bank, - v->instr.prg); -#endif - instr = snd_seq_instr_find(gus->gf1.ilist, &v->instr, 0, 1); - if (instr != NULL) { - if (instr->ops) { - if (!strcmp(instr->ops->instr_type, SNDRV_SEQ_INSTR_ID_SIMPLE)) - snd_gf1_simple_init(v); - } - snd_seq_instr_free_use(gus->gf1.ilist, instr); - } -} - -/* - * - */ - -static void event_sample(struct snd_seq_event *ev, struct snd_gus_port *p, - struct snd_gus_voice *v) -{ - if (v->sample_ops && v->sample_ops->sample_stop) - v->sample_ops->sample_stop(p->gus, v, SAMPLE_STOP_IMMEDIATELY); - v->instr.std = ev->data.sample.param.sample.std; - if (v->instr.std & 0xff000000) { /* private instrument */ - v->instr.std &= 0x00ffffff; - v->instr.std |= (unsigned int)ev->source.client << 24; - } - v->instr.bank = ev->data.sample.param.sample.bank; - v->instr.prg = ev->data.sample.param.sample.prg; - select_instrument(p->gus, v); -} - -static void event_cluster(struct snd_seq_event *ev, struct snd_gus_port *p, - struct snd_gus_voice *v) -{ - if (v->sample_ops && v->sample_ops->sample_stop) - v->sample_ops->sample_stop(p->gus, v, SAMPLE_STOP_IMMEDIATELY); - v->instr.cluster = ev->data.sample.param.cluster.cluster; - select_instrument(p->gus, v); -} - -static void event_start(struct snd_seq_event *ev, struct snd_gus_port *p, - struct snd_gus_voice *v) -{ - if (v->sample_ops && v->sample_ops->sample_start) - v->sample_ops->sample_start(p->gus, v, ev->data.sample.param.position); -} - -static void event_stop(struct snd_seq_event *ev, struct snd_gus_port *p, - struct snd_gus_voice *v) -{ - if (v->sample_ops && v->sample_ops->sample_stop) - v->sample_ops->sample_stop(p->gus, v, ev->data.sample.param.stop_mode); -} - -static void event_freq(struct snd_seq_event *ev, struct snd_gus_port *p, - struct snd_gus_voice *v) -{ - if (v->sample_ops && v->sample_ops->sample_freq) - v->sample_ops->sample_freq(p->gus, v, ev->data.sample.param.frequency); -} - -static void event_volume(struct snd_seq_event *ev, struct snd_gus_port *p, - struct snd_gus_voice *v) -{ - if (v->sample_ops && v->sample_ops->sample_volume) - v->sample_ops->sample_volume(p->gus, v, &ev->data.sample.param.volume); -} - -static void event_loop(struct snd_seq_event *ev, struct snd_gus_port *p, - struct snd_gus_voice *v) -{ - if (v->sample_ops && v->sample_ops->sample_loop) - v->sample_ops->sample_loop(p->gus, v, &ev->data.sample.param.loop); -} - -static void event_position(struct snd_seq_event *ev, struct snd_gus_port *p, - struct snd_gus_voice *v) -{ - if (v->sample_ops && v->sample_ops->sample_pos) - v->sample_ops->sample_pos(p->gus, v, ev->data.sample.param.position); -} - -static void event_private1(struct snd_seq_event *ev, struct snd_gus_port *p, - struct snd_gus_voice *v) -{ - if (v->sample_ops && v->sample_ops->sample_private1) - v->sample_ops->sample_private1(p->gus, v, (unsigned char *)&ev->data.sample.param.raw8); -} - -typedef void (gus_sample_event_handler_t)(struct snd_seq_event *ev, - struct snd_gus_port *p, - struct snd_gus_voice *v); -static gus_sample_event_handler_t *gus_sample_event_handlers[9] = { - event_sample, - event_cluster, - event_start, - event_stop, - event_freq, - event_volume, - event_loop, - event_position, - event_private1 -}; - -void snd_gus_sample_event(struct snd_seq_event *ev, struct snd_gus_port *p) -{ - int idx, voice; - struct snd_gus_card *gus = p->gus; - struct snd_gus_voice *v; - unsigned long flags; - - idx = ev->type - SNDRV_SEQ_EVENT_SAMPLE; - if (idx < 0 || idx > 8) - return; - for (voice = 0; voice < 32; voice++) { - v = &gus->gf1.voices[voice]; - if (v->use && v->client == ev->source.client && - v->port == ev->source.port && - v->index == ev->data.sample.channel) { - spin_lock_irqsave(&gus->event_lock, flags); - gus_sample_event_handlers[idx](ev, p, v); - spin_unlock_irqrestore(&gus->event_lock, flags); - return; - } - } -} diff --git a/sound/isa/gus/gus_simple.c b/sound/isa/gus/gus_simple.c deleted file mode 100644 index 39d121e2c8c4..000000000000 --- a/sound/isa/gus/gus_simple.c +++ /dev/null @@ -1,634 +0,0 @@ -/* - * Routines for Gravis UltraSound soundcards - Simple instrument handlers - * Copyright (c) by Jaroslav Kysela <perex@perex.cz> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include <sound/driver.h> -#include <linux/time.h> -#include <sound/core.h> -#include <sound/gus.h> -#include "gus_tables.h" - -/* - * - */ - -static void interrupt_wave(struct snd_gus_card *gus, struct snd_gus_voice *voice); -static void interrupt_volume(struct snd_gus_card *gus, struct snd_gus_voice *voice); -static void interrupt_effect(struct snd_gus_card *gus, struct snd_gus_voice *voice); - -static void sample_start(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position); -static void sample_stop(struct snd_gus_card *gus, struct snd_gus_voice *voice, int mode); -static void sample_freq(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_frequency_t freq); -static void sample_volume(struct snd_gus_card *card, struct snd_gus_voice *voice, struct snd_seq_ev_volume *volume); -static void sample_loop(struct snd_gus_card *card, struct snd_gus_voice *voice, struct snd_seq_ev_loop *loop); -static void sample_pos(struct snd_gus_card *card, struct snd_gus_voice *voice, snd_seq_position_t position); -static void sample_private1(struct snd_gus_card *card, struct snd_gus_voice *voice, unsigned char *data); - -static struct snd_gus_sample_ops sample_ops = { - sample_start, - sample_stop, - sample_freq, - sample_volume, - sample_loop, - sample_pos, - sample_private1 -}; - -#if 0 - -static void note_stop(struct snd_gus_card *gus, struct snd_gus_voice *voice, int wait); -static void note_wait(struct snd_gus_card *gus, struct snd_gus_voice *voice); -static void note_off(struct snd_gus_card *gus, struct snd_gus_voice *voice); -static void note_volume(struct snd_gus_card *card, struct snd_gus_voice *voice); -static void note_pitchbend(struct snd_gus_card *card, struct snd_gus_voice *voice); -static void note_vibrato(struct snd_gus_card *card, struct snd_gus_voice *voice); -static void note_tremolo(struct snd_gus_card *card, struct snd_gus_voice *voice); - -static struct snd_gus_note_handlers note_commands = { - note_stop, - note_wait, - note_off, - note_volume, - note_pitchbend, - note_vibrato, - note_tremolo -}; - -static void chn_trigger_down(struct snd_gus_card *card, ultra_channel_t *channel, ultra_instrument_t *instrument, unsigned char note, unsigned char velocity, unsigned char priority ); -static void chn_trigger_up( ultra_card_t *card, ultra_note_t *note ); -static void chn_control( ultra_card_t *card, ultra_channel_t *channel, unsigned short p1, unsigned short p2 ); - -static struct ULTRA_STRU_INSTRUMENT_CHANNEL_COMMANDS channel_commands = { - chn_trigger_down, - chn_trigger_up, - chn_control -}; - -#endif - -static void do_volume_envelope(struct snd_gus_card *card, struct snd_gus_voice *voice); -static void do_pan_envelope(struct snd_gus_card *card, struct snd_gus_voice *voice); - -/* - * - */ - -static void interrupt_wave(struct snd_gus_card *gus, struct snd_gus_voice *voice) -{ - spin_lock(&gus->event_lock); - snd_gf1_stop_voice(gus, voice->number); - spin_lock(&gus->reg_lock); - snd_gf1_select_voice(gus, voice->number); - snd_gf1_write16(gus, SNDRV_GF1_VW_VOLUME, 0); - spin_unlock(&gus->reg_lock); - voice->flags &= ~SNDRV_GF1_VFLG_RUNNING; - spin_unlock(&gus->event_lock); -} - -static void interrupt_volume(struct snd_gus_card *gus, struct snd_gus_voice *voice) -{ - spin_lock(&gus->event_lock); - if (voice->flags & SNDRV_GF1_VFLG_RUNNING) - do_volume_envelope(gus, voice); - else - snd_gf1_stop_voice(gus, voice->number); - spin_unlock(&gus->event_lock); -} - -static void interrupt_effect(struct snd_gus_card *gus, struct snd_gus_voice *voice) -{ - spin_lock(&gus->event_lock); - if ((voice->flags & (SNDRV_GF1_VFLG_RUNNING|SNDRV_GF1_VFLG_EFFECT_TIMER1)) == - (SNDRV_GF1_VFLG_RUNNING|SNDRV_GF1_VFLG_EFFECT_TIMER1)) - do_pan_envelope(gus, voice); - spin_unlock(&gus->event_lock); -} - -/* - * - */ - -static void do_volume_envelope(struct snd_gus_card *gus, struct snd_gus_voice *voice) -{ - unsigned short next, rate, old_volume; - int program_next_ramp; - unsigned long flags; - - if (!gus->gf1.volume_ramp) { - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL); - snd_gf1_write16(gus, SNDRV_GF1_VW_VOLUME, voice->gf1_volume); - /* printk("gf1_volume = 0x%x\n", voice->gf1_volume); */ - spin_unlock_irqrestore(&gus->reg_lock, flags); - return; - } - program_next_ramp = 0; - rate = next = 0; - while (1) { - program_next_ramp = 0; - rate = next = 0; - switch (voice->venv_state) { - case VENV_BEFORE: - voice->venv_state = VENV_ATTACK; - voice->venv_value_next = 0; - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL); - snd_gf1_write16(gus, SNDRV_GF1_VW_VOLUME, SNDRV_GF1_MIN_VOLUME); - spin_unlock_irqrestore(&gus->reg_lock, flags); - break; - case VENV_ATTACK: - voice->venv_state = VENV_SUSTAIN; - program_next_ramp++; - next = 255; - rate = gus->gf1.volume_ramp; - break; - case VENV_SUSTAIN: - voice->venv_state = VENV_RELEASE; - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL); - snd_gf1_write16(gus, SNDRV_GF1_VW_VOLUME, ((int)voice->gf1_volume * (int)voice->venv_value_next) / 255); - spin_unlock_irqrestore(&gus->reg_lock, flags); - return; - case VENV_RELEASE: - voice->venv_state = VENV_DONE; - program_next_ramp++; - next = 0; - rate = gus->gf1.volume_ramp; - break; - case VENV_DONE: - snd_gf1_stop_voice(gus, voice->number); - voice->flags &= ~SNDRV_GF1_VFLG_RUNNING; - return; - case VENV_VOLUME: - program_next_ramp++; - next = voice->venv_value_next; - rate = gus->gf1.volume_ramp; - voice->venv_state = voice->venv_state_prev; - break; - } - voice->venv_value_next = next; - if (!program_next_ramp) - continue; - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL); - old_volume = snd_gf1_read16(gus, SNDRV_GF1_VW_VOLUME) >> 8; - if (!rate) { - spin_unlock_irqrestore(&gus->reg_lock, flags); - continue; - } - next = (((int)voice->gf1_volume * (int)next) / 255) >> 8; - if (old_volume < SNDRV_GF1_MIN_OFFSET) - old_volume = SNDRV_GF1_MIN_OFFSET; - if (next < SNDRV_GF1_MIN_OFFSET) - next = SNDRV_GF1_MIN_OFFSET; - if (next > SNDRV_GF1_MAX_OFFSET) - next = SNDRV_GF1_MAX_OFFSET; - if (old_volume == next) { - spin_unlock_irqrestore(&gus->reg_lock, flags); - continue; - } - voice->volume_control &= ~0xc3; - voice->volume_control |= 0x20; - if (old_volume > next) { - snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_START, next); - snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_END, old_volume); - voice->volume_control |= 0x40; - } else { - snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_START, old_volume); - snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_END, next); - } - snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_RATE, rate); - snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_CONTROL, voice->volume_control); - if (!gus->gf1.enh_mode) { - snd_gf1_delay(gus); - snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_CONTROL, voice->volume_control); - } - spin_unlock_irqrestore(&gus->reg_lock, flags); - return; - } -} - -static void do_pan_envelope(struct snd_gus_card *gus, struct snd_gus_voice *voice) -{ - unsigned long flags; - unsigned char old_pan; - -#if 0 - snd_gf1_select_voice(gus, voice->number); - printk(" -%i- do_pan_envelope - flags = 0x%x (0x%x -> 0x%x)\n", - voice->number, - voice->flags, - voice->gf1_pan, - snd_gf1_i_read8(gus, SNDRV_GF1_VB_PAN) & 0x0f); -#endif - if (gus->gf1.enh_mode) { - voice->flags &= ~(SNDRV_GF1_VFLG_EFFECT_TIMER1|SNDRV_GF1_VFLG_PAN); - return; - } - if (!gus->gf1.smooth_pan) { - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - snd_gf1_write8(gus, SNDRV_GF1_VB_PAN, voice->gf1_pan); - spin_unlock_irqrestore(&gus->reg_lock, flags); - return; - } - if (!(voice->flags & SNDRV_GF1_VFLG_PAN)) /* before */ - voice->flags |= SNDRV_GF1_VFLG_EFFECT_TIMER1|SNDRV_GF1_VFLG_PAN; - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - old_pan = snd_gf1_read8(gus, SNDRV_GF1_VB_PAN) & 0x0f; - if (old_pan > voice->gf1_pan ) - old_pan--; - if (old_pan < voice->gf1_pan) - old_pan++; - snd_gf1_write8(gus, SNDRV_GF1_VB_PAN, old_pan); - spin_unlock_irqrestore(&gus->reg_lock, flags); - if (old_pan == voice->gf1_pan) /* the goal was reached */ - voice->flags &= ~(SNDRV_GF1_VFLG_EFFECT_TIMER1|SNDRV_GF1_VFLG_PAN); -#if 0 - snd_gf1_select_voice(gus, voice->number); - printk(" -%i- (1) do_pan_envelope - flags = 0x%x (0x%x -> 0x%x)\n", - voice->number, - voice->flags, - voice->gf1_pan, - snd_gf1_i_read8(gus, GF1_VB_PAN) & 0x0f); -#endif -} - -static void set_enhanced_pan(struct snd_gus_card *gus, struct snd_gus_voice *voice, unsigned short pan) -{ - unsigned long flags; - unsigned short vlo, vro; - - vlo = SNDRV_GF1_ATTEN((SNDRV_GF1_ATTEN_TABLE_SIZE-1) - pan); - vro = SNDRV_GF1_ATTEN(pan); - if (pan != SNDRV_GF1_ATTEN_TABLE_SIZE - 1 && pan != 0) { - vlo >>= 1; - vro >>= 1; - } - vlo <<= 4; - vro <<= 4; -#if 0 - printk("vlo = 0x%x (0x%x), vro = 0x%x (0x%x)\n", - vlo, snd_gf1_i_read16(gus, GF1_VW_OFFSET_LEFT), - vro, snd_gf1_i_read16(gus, GF1_VW_OFFSET_RIGHT)); -#endif - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - snd_gf1_write16(gus, SNDRV_GF1_VW_OFFSET_LEFT_FINAL, vlo); - snd_gf1_write16(gus, SNDRV_GF1_VW_OFFSET_RIGHT_FINAL, vro); - spin_unlock_irqrestore(&gus->reg_lock, flags); - voice->vlo = vlo; - voice->vro = vro; -} - -/* - * - */ - -static void sample_start(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position) -{ - unsigned long flags; - unsigned int begin, addr, addr_end, addr_start; - int w_16; - struct simple_instrument *simple; - struct snd_seq_kinstr *instr; - - instr = snd_seq_instr_find(gus->gf1.ilist, &voice->instr, 0, 1); - if (instr == NULL) - return; - voice->instr = instr->instr; /* copy ID to speedup aliases */ - simple = KINSTR_DATA(instr); - begin = simple->address.memory << 4; - w_16 = simple->format & SIMPLE_WAVE_16BIT ? 0x04 : 0; - addr_start = simple->loop_start; - if (simple->format & SIMPLE_WAVE_LOOP) { - addr_end = simple->loop_end; - } else { - addr_end = (simple->size << 4) - (w_16 ? 40 : 24); - } - if (simple->format & SIMPLE_WAVE_BACKWARD) { - addr = simple->loop_end; - if (position < simple->loop_end) - addr -= position; - } else { - addr = position; - } - voice->control = 0x00; - voice->mode = 0x20; /* enable offset registers */ - if (simple->format & SIMPLE_WAVE_16BIT) - voice->control |= 0x04; - if (simple->format & SIMPLE_WAVE_BACKWARD) - voice->control |= 0x40; - if (simple->format & SIMPLE_WAVE_LOOP) { - voice->control |= 0x08; - } else { - voice->control |= 0x20; - } - if (simple->format & SIMPLE_WAVE_BIDIR) - voice->control |= 0x10; - if (simple->format & SIMPLE_WAVE_ULAW) - voice->mode |= 0x40; - if (w_16) { - addr = ((addr << 1) & ~0x1f) | (addr & 0x0f); - addr_start = ((addr_start << 1) & ~0x1f) | (addr_start & 0x0f); - addr_end = ((addr_end << 1) & ~0x1f) | (addr_end & 0x0f); - } - addr += begin; - addr_start += begin; - addr_end += begin; - snd_gf1_stop_voice(gus, voice->number); - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - snd_gf1_write16(gus, SNDRV_GF1_VW_FREQUENCY, voice->fc_register + voice->fc_lfo); - voice->venv_state = VENV_BEFORE; - voice->volume_control = 0x03; - snd_gf1_write_addr(gus, SNDRV_GF1_VA_START, addr_start, w_16); - snd_gf1_write_addr(gus, SNDRV_GF1_VA_END, addr_end, w_16); - snd_gf1_write_addr(gus, SNDRV_GF1_VA_CURRENT, addr, w_16); - if (!gus->gf1.enh_mode) { - snd_gf1_write8(gus, SNDRV_GF1_VB_PAN, voice->gf1_pan); - } else { - snd_gf1_write16(gus, SNDRV_GF1_VW_OFFSET_LEFT, voice->vlo); - snd_gf1_write16(gus, SNDRV_GF1_VW_OFFSET_LEFT_FINAL, voice->vlo); - snd_gf1_write16(gus, SNDRV_GF1_VW_OFFSET_RIGHT, voice->vro); - snd_gf1_write16(gus, SNDRV_GF1_VW_OFFSET_RIGHT_FINAL, voice->vro); - snd_gf1_write8(gus, SNDRV_GF1_VB_ACCUMULATOR, voice->effect_accumulator); - snd_gf1_write16(gus, SNDRV_GF1_VW_EFFECT_VOLUME, voice->gf1_effect_volume); - snd_gf1_write16(gus, SNDRV_GF1_VW_EFFECT_VOLUME_FINAL, voice->gf1_effect_volume); - } - spin_unlock_irqrestore(&gus->reg_lock, flags); - do_volume_envelope(gus, voice); - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - if (gus->gf1.enh_mode) - snd_gf1_write8(gus, SNDRV_GF1_VB_MODE, voice->mode); - snd_gf1_write8(gus, SNDRV_GF1_VB_ADDRESS_CONTROL, voice->control); - if (!gus->gf1.enh_mode) { - snd_gf1_delay(gus); - snd_gf1_write8(gus, SNDRV_GF1_VB_ADDRESS_CONTROL, voice->control ); - } - spin_unlock_irqrestore(&gus->reg_lock, flags); -#if 0 - snd_gf1_print_voice_registers(gus); -#endif - voice->flags |= SNDRV_GF1_VFLG_RUNNING; - snd_seq_instr_free_use(gus->gf1.ilist, instr); -} - -static void sample_stop(struct snd_gus_card *gus, struct snd_gus_voice *voice, int mode) -{ - unsigned char control; - unsigned long flags; - - if (!(voice->flags & SNDRV_GF1_VFLG_RUNNING)) - return; - switch (mode) { - default: - if (gus->gf1.volume_ramp > 0) { - if (voice->venv_state < VENV_RELEASE) { - voice->venv_state = VENV_RELEASE; - do_volume_envelope(gus, voice); - } - } - if (mode != SAMPLE_STOP_VENVELOPE) { - snd_gf1_stop_voice(gus, voice->number); - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - snd_gf1_write16(gus, SNDRV_GF1_VW_VOLUME, SNDRV_GF1_MIN_VOLUME); - spin_unlock_irqrestore(&gus->reg_lock, flags); - voice->flags &= ~SNDRV_GF1_VFLG_RUNNING; - } - break; - case SAMPLE_STOP_LOOP: /* disable loop only */ - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - control = snd_gf1_read8(gus, SNDRV_GF1_VB_ADDRESS_CONTROL); - control &= ~(0x83 | 0x04); - control |= 0x20; - snd_gf1_write8(gus, SNDRV_GF1_VB_ADDRESS_CONTROL, control); - spin_unlock_irqrestore(&gus->reg_lock, flags); - break; - } -} - -static void sample_freq(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_frequency_t freq) -{ - unsigned long flags; - - spin_lock_irqsave(&gus->reg_lock, flags); - voice->fc_register = snd_gf1_translate_freq(gus, freq); - snd_gf1_select_voice(gus, voice->number); - snd_gf1_write16(gus, SNDRV_GF1_VW_FREQUENCY, voice->fc_register + voice->fc_lfo); - spin_unlock_irqrestore(&gus->reg_lock, flags); -} - -static void sample_volume(struct snd_gus_card *gus, struct snd_gus_voice *voice, struct snd_seq_ev_volume *volume) -{ - if (volume->volume >= 0) { - volume->volume &= 0x3fff; - voice->gf1_volume = snd_gf1_lvol_to_gvol_raw(volume->volume << 2) << 4; - voice->venv_state_prev = VENV_SUSTAIN; - voice->venv_state = VENV_VOLUME; - do_volume_envelope(gus, voice); - } - if (volume->lr >= 0) { - volume->lr &= 0x3fff; - if (!gus->gf1.enh_mode) { - voice->gf1_pan = (volume->lr >> 10) & 15; - if (!gus->gf1.full_range_pan) { - if (voice->gf1_pan == 0) - voice->gf1_pan++; - if (voice->gf1_pan == 15) - voice->gf1_pan--; - } - voice->flags &= ~SNDRV_GF1_VFLG_PAN; /* before */ - do_pan_envelope(gus, voice); - } else { - set_enhanced_pan(gus, voice, volume->lr >> 7); - } - } -} - -static void sample_loop(struct snd_gus_card *gus, struct snd_gus_voice *voice, struct snd_seq_ev_loop *loop) -{ - unsigned long flags; - int w_16 = voice->control & 0x04; - unsigned int begin, addr_start, addr_end; - struct simple_instrument *simple; - struct snd_seq_kinstr *instr; - -#if 0 - printk("voice_loop: start = 0x%x, end = 0x%x\n", loop->start, loop->end); -#endif - instr = snd_seq_instr_find(gus->gf1.ilist, &voice->instr, 0, 1); - if (instr == NULL) - return; - voice->instr = instr->instr; /* copy ID to speedup aliases */ - simple = KINSTR_DATA(instr); - begin = simple->address.memory; - addr_start = loop->start; - addr_end = loop->end; - addr_start = (((addr_start << 1) & ~0x1f) | (addr_start & 0x0f)) + begin; - addr_end = (((addr_end << 1) & ~0x1f) | (addr_end & 0x0f)) + begin; - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - snd_gf1_write_addr(gus, SNDRV_GF1_VA_START, addr_start, w_16); - snd_gf1_write_addr(gus, SNDRV_GF1_VA_END, addr_end, w_16); - spin_unlock_irqrestore(&gus->reg_lock, flags); - snd_seq_instr_free_use(gus->gf1.ilist, instr); -} - -static void sample_pos(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position) -{ - unsigned long flags; - int w_16 = voice->control & 0x04; - unsigned int begin, addr; - struct simple_instrument *simple; - struct snd_seq_kinstr *instr; - -#if 0 - printk("voice_loop: start = 0x%x, end = 0x%x\n", loop->start, loop->end); -#endif - instr = snd_seq_instr_find(gus->gf1.ilist, &voice->instr, 0, 1); - if (instr == NULL) - return; - voice->instr = instr->instr; /* copy ID to speedup aliases */ - simple = KINSTR_DATA(instr); - begin = simple->address.memory; - addr = (((position << 1) & ~0x1f) | (position & 0x0f)) + begin; - spin_lock_irqsave(&gus->reg_lock, flags); - snd_gf1_select_voice(gus, voice->number); - snd_gf1_write_addr(gus, SNDRV_GF1_VA_CURRENT, addr, w_16); - spin_unlock_irqrestore(&gus->reg_lock, flags); - snd_seq_instr_free_use(gus->gf1.ilist, instr); -} - -#if 0 - -static unsigned char get_effects_mask( ultra_card_t *card, int value ) -{ - if ( value > 7 ) return 0; - if ( card -> gf1.effects && card -> gf1.effects -> chip_type == ULTRA_EFFECT_CHIP_INTERWAVE ) - return card -> gf1.effects -> chip.interwave.voice_output[ value ]; - return 0; -} - -#endif - -static void sample_private1(struct snd_gus_card *card, struct snd_gus_voice *voice, unsigned char *data) -{ -#if 0 - unsigned long flags; - unsigned char uc; - - switch ( *data ) { - case ULTRA_PRIV1_IW_EFFECT: - uc = get_effects_mask( card, ultra_get_byte( data, 4 ) ); - uc |= get_effects_mask( card, ultra_get_byte( data, 4 ) >> 4 ); - uc |= get_effects_mask( card, ultra_get_byte( data, 5 ) ); - uc |= get_effects_mask( card, ultra_get_byte( data, 5 ) >> 4 ); - voice -> data.simple.effect_accumulator = uc; - voice -> data.simple.effect_volume = ultra_translate_voice_volume( card, ultra_get_word( data, 2 ) ) << 4; - if ( !card -> gf1.enh_mode ) return; - if ( voice -> flags & VFLG_WAIT_FOR_START ) return; - if ( voice -> flags & VFLG_RUNNING ) - { - CLI( &flags ); - gf1_select_voice( card, voice -> number ); - ultra_write8( card, GF1_VB_ACCUMULATOR, voice -> data.simple.effect_accumulator ); - ultra_write16( card, GF1_VW_EFFECT_VOLUME_FINAL, voice -> data.simple.effect_volume ); - STI( &flags ); - } - break; - case ULTRA_PRIV1_IW_LFO: - ultra_lfo_command( card, voice -> number, data ); - } -#endif -} - -#if 0 - -/* - * - */ - -static void note_stop( ultra_card_t *card, ultra_voice_t *voice, int wait ) -{ -} - -static void note_wait( ultra_card_t *card, ultra_voice_t *voice ) -{ -} - -static void note_off( ultra_card_t *card, ultra_voice_t *voice ) -{ -} - -static void note_volume( ultra_card_t *card, ultra_voice_t *voice ) -{ -} - -static void note_pitchbend( ultra_card_t *card, ultra_voice_t *voice ) -{ -} - -static void note_vibrato( ultra_card_t *card, ultra_voice_t *voice ) -{ -} - -static void note_tremolo( ultra_card_t *card, ultra_voice_t *voice ) -{ -} - -/* - * - */ - -static void chn_trigger_down( ultra_card_t *card, ultra_channel_t *channel, ultra_instrument_t *instrument, unsigned char note, unsigned char velocity, unsigned char priority ) -{ -} - -static void chn_trigger_up( ultra_card_t *card, ultra_note_t *note ) -{ -} - -static void chn_control( ultra_card_t *card, ultra_channel_t *channel, unsigned short p1, unsigned short p2 ) -{ -} - -/* - * - */ - -#endif - -void snd_gf1_simple_init(struct snd_gus_voice *voice) -{ - voice->handler_wave = interrupt_wave; - voice->handler_volume = interrupt_volume; - voice->handler_effect = interrupt_effect; - voice->volume_change = NULL; - voice->sample_ops = &sample_ops; -} diff --git a/sound/isa/gus/gus_synth.c b/sound/isa/gus/gus_synth.c deleted file mode 100644 index 2c2051782aa2..000000000000 --- a/sound/isa/gus/gus_synth.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Routines for Gravis UltraSound soundcards - Synthesizer - * Copyright (c) by Jaroslav Kysela <perex@perex.cz> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include <sound/driver.h> -#include <linux/init.h> -#include <linux/time.h> -#include <sound/core.h> -#include <sound/gus.h> -#include <sound/seq_device.h> - -MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); -MODULE_DESCRIPTION("Routines for Gravis UltraSound soundcards - Synthesizer"); -MODULE_LICENSE("GPL"); - -/* - * - */ - -static void snd_gus_synth_free_voices(struct snd_gus_card * gus, int client, int port) -{ - int idx; - struct snd_gus_voice * voice; - - for (idx = 0; idx < 32; idx++) { - voice = &gus->gf1.voices[idx]; - if (voice->use && voice->client == client && voice->port == port) - snd_gf1_free_voice(gus, voice); - } -} - -static int snd_gus_synth_use(void *private_data, struct snd_seq_port_subscribe *info) -{ - struct snd_gus_port * port = private_data; - struct snd_gus_card * gus = port->gus; - struct snd_gus_voice * voice; - unsigned int idx; - - if (info->voices > 32) - return -EINVAL; - mutex_lock(&gus->register_mutex); - if (!snd_gus_use_inc(gus)) { - mutex_unlock(&gus->register_mutex); - return -EFAULT; - } - for (idx = 0; idx < info->voices; idx++) { - voice = snd_gf1_alloc_voice(gus, SNDRV_GF1_VOICE_TYPE_SYNTH, info->sender.client, info->sender.port); - if (voice == NULL) { - snd_gus_synth_free_voices(gus, info->sender.client, info->sender.port); - snd_gus_use_dec(gus); - mutex_unlock(&gus->register_mutex); - return -EBUSY; - } - voice->index = idx; - } - mutex_unlock(&gus->register_mutex); - return 0; -} - -static int snd_gus_synth_unuse(void *private_data, struct snd_seq_port_subscribe *info) -{ - struct snd_gus_port * port = private_data; - struct snd_gus_card * gus = port->gus; - - mutex_lock(&gus->register_mutex); - snd_gus_synth_free_voices(gus, info->sender.client, info->sender.port); - snd_gus_use_dec(gus); - mutex_unlock(&gus->register_mutex); - return 0; -} - -/* - * - */ - -static void snd_gus_synth_free_private_instruments(struct snd_gus_port *p, int client) -{ - struct snd_seq_instr_header ifree; - - memset(&ifree, 0, sizeof(ifree)); - ifree.cmd = SNDRV_SEQ_INSTR_FREE_CMD_PRIVATE; - snd_seq_instr_list_free_cond(p->gus->gf1.ilist, &ifree, client, 0); -} - -static int snd_gus_synth_event_input(struct snd_seq_event *ev, int direct, - void *private_data, int atomic, int hop) -{ - struct snd_gus_port * p = private_data; - - snd_assert(p != NULL, return -EINVAL); - if (ev->type >= SNDRV_SEQ_EVENT_SAMPLE && - ev->type <= SNDRV_SEQ_EVENT_SAMPLE_PRIVATE1) { - snd_gus_sample_event(ev, p); - return 0; - } - if (ev->source.client == SNDRV_SEQ_CLIENT_SYSTEM && - ev->source.port == SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE) { - if (ev->type == SNDRV_SEQ_EVENT_CLIENT_EXIT) { - snd_gus_synth_free_private_instruments(p, ev->data.addr.client); - return 0; - } - } - if (direct) { - if (ev->type >= SNDRV_SEQ_EVENT_INSTR_BEGIN) { - snd_seq_instr_event(&p->gus->gf1.iwffff_ops.kops, - p->gus->gf1.ilist, - ev, - p->gus->gf1.seq_client, - atomic, hop); - return 0; - } - } - return 0; -} - -static void snd_gus_synth_instr_notify(void *private_data, - struct snd_seq_kinstr *instr, - int what) -{ - unsigned int idx; - struct snd_gus_card *gus = private_data; - struct snd_gus_voice *pvoice; - unsigned long flags; - - spin_lock_irqsave(&gus->event_lock, flags); - for (idx = 0; idx < 32; idx++) { - pvoice = &gus->gf1.voices[idx]; - if (pvoice->use && !memcmp(&pvoice->instr, &instr->instr, sizeof(pvoice->instr))) { - if (pvoice->sample_ops && pvoice->sample_ops->sample_stop) { - pvoice->sample_ops->sample_stop(gus, pvoice, SAMPLE_STOP_IMMEDIATELY); - } else { - snd_gf1_stop_voice(gus, pvoice->number); - pvoice->flags &= ~SNDRV_GF1_VFLG_RUNNING; - } - } - } - spin_unlock_irqrestore(&gus->event_lock, flags); -} - -/* - * - */ - -static void snd_gus_synth_free_port(void *private_data) -{ - struct snd_gus_port * p = private_data; - - if (p) - snd_midi_channel_free_set(p->chset); -} - -static int snd_gus_synth_create_port(struct snd_gus_card * gus, int idx) -{ - struct snd_gus_port * p; - struct snd_seq_port_callback callbacks; - char name[32]; - int result; - - p = &gus->gf1.seq_ports[idx]; - p->chset = snd_midi_channel_alloc_set(16); - if (p->chset == NULL) - return -ENOMEM; - p->chset->private_data = p; - p->gus = gus; - p->client = gus->gf1.seq_client; - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.owner = THIS_MODULE; - callbacks.use = snd_gus_synth_use; - callbacks.unuse = snd_gus_synth_unuse; - callbacks.event_input = snd_gus_synth_event_input; - callbacks.private_free = snd_gus_synth_free_port; - callbacks.private_data = p; - - sprintf(name, "%s port %i", gus->interwave ? "AMD InterWave" : "GF1", idx); - p->chset->port = snd_seq_event_port_attach(gus->gf1.seq_client, - &callbacks, - SNDRV_SEQ_PORT_CAP_WRITE | SNDRV_SEQ_PORT_CAP_SUBS_WRITE, - SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE | - SNDRV_SEQ_PORT_TYPE_SYNTH | - SNDRV_SEQ_PORT_TYPE_HARDWARE | - SNDRV_SEQ_PORT_TYPE_SYNTHESIZER, - 16, 0, - name); - if (p->chset->port < 0) { - result = p->chset->port; - snd_gus_synth_free_port(p); - return result; - } - p->port = p->chset->port; - return 0; -} - -/* - * - */ - -static int snd_gus_synth_new_device(struct snd_seq_device *dev) -{ - struct snd_gus_card *gus; - int client, i; - struct snd_seq_port_subscribe sub; - struct snd_iwffff_ops *iwops; - struct snd_gf1_ops *gf1ops; - struct snd_simple_ops *simpleops; - - gus = *(struct snd_gus_card **)SNDRV_SEQ_DEVICE_ARGPTR(dev); - if (gus == NULL) - return -EINVAL; - - mutex_init(&gus->register_mutex); - gus->gf1.seq_client = -1; - - /* allocate new client */ - client = gus->gf1.seq_client = - snd_seq_create_kernel_client(gus->card, 1, gus->interwave ? - "AMD InterWave" : "GF1"); - if (client < 0) - return client; - - for (i = 0; i < 4; i++) - snd_gus_synth_create_port(gus, i); - - gus->gf1.ilist = snd_seq_instr_list_new(); - if (gus->gf1.ilist == NULL) { - snd_seq_delete_kernel_client(client); - gus->gf1.seq_client = -1; - return -ENOMEM; - } - gus->gf1.ilist->flags = SNDRV_SEQ_INSTR_FLG_DIRECT; - - simpleops = &gus->gf1.simple_ops; - snd_seq_simple_init(simpleops, gus, NULL); - simpleops->put_sample = snd_gus_simple_put_sample; - simpleops->get_sample = snd_gus_simple_get_sample; - simpleops->remove_sample = snd_gus_simple_remove_sample; - simpleops->notify = snd_gus_synth_instr_notify; - - gf1ops = &gus->gf1.gf1_ops; - snd_seq_gf1_init(gf1ops, gus, &simpleops->kops); - gf1ops->put_sample = snd_gus_gf1_put_sample; - gf1ops->get_sample = snd_gus_gf1_get_sample; - gf1ops->remove_sample = snd_gus_gf1_remove_sample; - gf1ops->notify = snd_gus_synth_instr_notify; - - iwops = &gus->gf1.iwffff_ops; - snd_seq_iwffff_init(iwops, gus, &gf1ops->kops); - iwops->put_sample = snd_gus_iwffff_put_sample; - iwops->get_sample = snd_gus_iwffff_get_sample; - iwops->remove_sample = snd_gus_iwffff_remove_sample; - iwops->notify = snd_gus_synth_instr_notify; - - memset(&sub, 0, sizeof(sub)); - sub.sender.client = SNDRV_SEQ_CLIENT_SYSTEM; - sub.sender.port = SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE; - sub.dest.client = client; - sub.dest.port = 0; - snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT, &sub); - - return 0; -} - -static int snd_gus_synth_delete_device(struct snd_seq_device *dev) -{ - struct snd_gus_card *gus; - - gus = *(struct snd_gus_card **)SNDRV_SEQ_DEVICE_ARGPTR(dev); - if (gus == NULL) - return -EINVAL; - - if (gus->gf1.seq_client >= 0) { - snd_seq_delete_kernel_client(gus->gf1.seq_client); - gus->gf1.seq_client = -1; - } - if (gus->gf1.ilist) - snd_seq_instr_list_free(&gus->gf1.ilist); - return 0; -} - -static int __init alsa_gus_synth_init(void) -{ - static struct snd_seq_dev_ops ops = { - snd_gus_synth_new_device, - snd_gus_synth_delete_device - }; - - return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_GUS, &ops, - sizeof(struct snd_gus_card *)); -} - -static void __exit alsa_gus_synth_exit(void) -{ - snd_seq_device_unregister_driver(SNDRV_SEQ_DEV_ID_GUS); -} - -module_init(alsa_gus_synth_init) -module_exit(alsa_gus_synth_exit) |