2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
|
|
|
|
*
|
|
|
|
* Routines for control of EMU10K1 WaveTable synth
|
|
|
|
*
|
|
|
|
* 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 "emu10k1_synth_local.h"
|
|
|
|
#include <linux/init.h>
|
2011-07-15 16:38:28 +00:00
|
|
|
#include <linux/module.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Takashi Iwai");
|
|
|
|
MODULE_DESCRIPTION("Routines for control of EMU10K1 WaveTable synth");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* create a new hardware dependent device for Emu10k1
|
|
|
|
*/
|
2015-02-12 12:43:22 +00:00
|
|
|
static int snd_emu10k1_synth_probe(struct device *_dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2015-02-12 12:43:22 +00:00
|
|
|
struct snd_seq_device *dev = to_seq_dev(_dev);
|
2007-11-10 17:55:14 +00:00
|
|
|
struct snd_emux *emux;
|
2005-11-17 13:50:13 +00:00
|
|
|
struct snd_emu10k1 *hw;
|
|
|
|
struct snd_emu10k1_synth_arg *arg;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
arg = SNDRV_SEQ_DEVICE_ARGPTR(dev);
|
|
|
|
if (arg == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (arg->seq_ports <= 0)
|
|
|
|
return 0; /* nothing */
|
|
|
|
if (arg->max_voices < 1)
|
|
|
|
arg->max_voices = 1;
|
|
|
|
else if (arg->max_voices > 64)
|
|
|
|
arg->max_voices = 64;
|
|
|
|
|
2007-11-10 17:55:14 +00:00
|
|
|
if (snd_emux_new(&emux) < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2007-11-10 17:55:14 +00:00
|
|
|
snd_emu10k1_ops_setup(emux);
|
|
|
|
hw = arg->hwptr;
|
|
|
|
emux->hw = hw;
|
|
|
|
emux->max_voices = arg->max_voices;
|
|
|
|
emux->num_ports = arg->seq_ports;
|
|
|
|
emux->pitch_shift = -501;
|
|
|
|
emux->memhdr = hw->memhdr;
|
|
|
|
/* maximum two ports */
|
|
|
|
emux->midi_ports = arg->seq_ports < 2 ? arg->seq_ports : 2;
|
|
|
|
/* audigy has two external midis */
|
|
|
|
emux->midi_devidx = hw->audigy ? 2 : 1;
|
|
|
|
emux->linear_panning = 0;
|
|
|
|
emux->hwdep_idx = 2; /* FIXED */
|
|
|
|
|
|
|
|
if (snd_emux_register(emux, dev->card, arg->index, "Emu10k1") < 0) {
|
|
|
|
snd_emux_free(emux);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&hw->voice_lock, flags);
|
2007-11-10 17:55:14 +00:00
|
|
|
hw->synth = emux;
|
2005-04-16 22:20:36 +00:00
|
|
|
hw->get_synth_voice = snd_emu10k1_synth_get_voice;
|
|
|
|
spin_unlock_irqrestore(&hw->voice_lock, flags);
|
|
|
|
|
2007-11-10 17:55:14 +00:00
|
|
|
dev->driver_data = emux;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-12 12:43:22 +00:00
|
|
|
static int snd_emu10k1_synth_remove(struct device *_dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2015-02-12 12:43:22 +00:00
|
|
|
struct snd_seq_device *dev = to_seq_dev(_dev);
|
2007-11-10 17:55:14 +00:00
|
|
|
struct snd_emux *emux;
|
2005-11-17 13:50:13 +00:00
|
|
|
struct snd_emu10k1 *hw;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (dev->driver_data == NULL)
|
|
|
|
return 0; /* not registered actually */
|
|
|
|
|
2007-11-10 17:55:14 +00:00
|
|
|
emux = dev->driver_data;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-11-10 17:55:14 +00:00
|
|
|
hw = emux->hw;
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_lock_irqsave(&hw->voice_lock, flags);
|
|
|
|
hw->synth = NULL;
|
|
|
|
hw->get_synth_voice = NULL;
|
|
|
|
spin_unlock_irqrestore(&hw->voice_lock, flags);
|
|
|
|
|
2007-11-10 17:55:14 +00:00
|
|
|
snd_emux_free(emux);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* INIT part
|
|
|
|
*/
|
|
|
|
|
2015-02-12 12:43:22 +00:00
|
|
|
static struct snd_seq_driver emu10k1_synth_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = KBUILD_MODNAME,
|
|
|
|
.probe = snd_emu10k1_synth_probe,
|
|
|
|
.remove = snd_emu10k1_synth_remove,
|
|
|
|
},
|
|
|
|
.id = SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH,
|
|
|
|
.argsize = sizeof(struct snd_emu10k1_synth_arg),
|
|
|
|
};
|
|
|
|
|
|
|
|
module_snd_seq_driver(emu10k1_synth_driver);
|