2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
|
|
|
|
*
|
|
|
|
* Routines for control of EMU WaveTable chip
|
|
|
|
*
|
|
|
|
* 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/wait.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/slab.h>
|
2005-06-23 15:09:02 +08:00
|
|
|
#include <linux/string.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/emux_synth.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include "emux_voice.h"
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Takashi Iwai");
|
|
|
|
MODULE_DESCRIPTION("Routines for control of EMU WaveTable chip");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* create a new hardware dependent device for Emu8000/Emu10k1
|
|
|
|
*/
|
2005-11-17 21:24:47 +08:00
|
|
|
int snd_emux_new(struct snd_emux **remu)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-17 21:24:47 +08:00
|
|
|
struct snd_emux *emu;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
*remu = NULL;
|
[ALSA] Replace with kzalloc() - others
Documentation,SA11xx UDA1341 driver,Generic drivers,MPU401 UART,OPL3
OPL4,Digigram VX core,I2C cs8427,I2C lib core,I2C tea6330t,L3 drivers
AK4114 receiver,AK4117 receiver,PDAudioCF driver,PPC PMAC driver
SPARC AMD7930 driver,SPARC cs4231 driver,Synth,Common EMU synth
USB generic driver,USB USX2Y
Replace kcalloc(1,..) with kzalloc().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-09-09 20:22:34 +08:00
|
|
|
emu = kzalloc(sizeof(*emu), GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (emu == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
spin_lock_init(&emu->voice_lock);
|
2006-01-16 23:31:42 +08:00
|
|
|
mutex_init(&emu->register_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
emu->client = -1;
|
|
|
|
#ifdef CONFIG_SND_SEQUENCER_OSS
|
|
|
|
emu->oss_synth = NULL;
|
|
|
|
#endif
|
|
|
|
emu->max_voices = 0;
|
|
|
|
emu->use_time = 0;
|
|
|
|
|
|
|
|
init_timer(&emu->tlist);
|
|
|
|
emu->tlist.function = snd_emux_timer_callback;
|
|
|
|
emu->tlist.data = (unsigned long)emu;
|
|
|
|
emu->timer_active = 0;
|
|
|
|
|
|
|
|
*remu = emu;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-28 21:13:40 +08:00
|
|
|
EXPORT_SYMBOL(snd_emux_new);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
2005-11-17 21:24:47 +08:00
|
|
|
static int sf_sample_new(void *private_data, struct snd_sf_sample *sp,
|
|
|
|
struct snd_util_memhdr *hdr,
|
|
|
|
const void __user *buf, long count)
|
2005-11-17 17:50:13 +08:00
|
|
|
{
|
2005-11-17 21:24:47 +08:00
|
|
|
struct snd_emux *emu = private_data;
|
2005-11-17 17:50:13 +08:00
|
|
|
return emu->ops.sample_new(emu, sp, hdr, buf, count);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:24:47 +08:00
|
|
|
static int sf_sample_free(void *private_data, struct snd_sf_sample *sp,
|
|
|
|
struct snd_util_memhdr *hdr)
|
2005-11-17 17:50:13 +08:00
|
|
|
{
|
2005-11-17 21:24:47 +08:00
|
|
|
struct snd_emux *emu = private_data;
|
2005-11-17 17:50:13 +08:00
|
|
|
return emu->ops.sample_free(emu, sp, hdr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sf_sample_reset(void *private_data)
|
|
|
|
{
|
2005-11-17 21:24:47 +08:00
|
|
|
struct snd_emux *emu = private_data;
|
2005-11-17 17:50:13 +08:00
|
|
|
emu->ops.sample_reset(emu);
|
|
|
|
}
|
|
|
|
|
2005-11-17 21:24:47 +08:00
|
|
|
int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, char *name)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int err;
|
2005-11-17 21:24:47 +08:00
|
|
|
struct snd_sf_callback sf_cb;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
snd_assert(emu->hw != NULL, return -EINVAL);
|
|
|
|
snd_assert(emu->max_voices > 0, return -EINVAL);
|
|
|
|
snd_assert(card != NULL, return -EINVAL);
|
|
|
|
snd_assert(name != NULL, return -EINVAL);
|
|
|
|
|
|
|
|
emu->card = card;
|
2005-06-23 15:09:02 +08:00
|
|
|
emu->name = kstrdup(name, GFP_KERNEL);
|
2005-11-17 21:24:47 +08:00
|
|
|
emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice),
|
|
|
|
GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (emu->voices == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/* create soundfont list */
|
|
|
|
memset(&sf_cb, 0, sizeof(sf_cb));
|
|
|
|
sf_cb.private_data = emu;
|
2005-11-17 17:50:13 +08:00
|
|
|
if (emu->ops.sample_new)
|
|
|
|
sf_cb.sample_new = sf_sample_new;
|
|
|
|
if (emu->ops.sample_free)
|
|
|
|
sf_cb.sample_free = sf_sample_free;
|
|
|
|
if (emu->ops.sample_reset)
|
|
|
|
sf_cb.sample_reset = sf_sample_reset;
|
2005-04-17 06:20:36 +08:00
|
|
|
emu->sflist = snd_sf_new(&sf_cb, emu->memhdr);
|
|
|
|
if (emu->sflist == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
if ((err = snd_emux_init_hwdep(emu)) < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
snd_emux_init_voices(emu);
|
|
|
|
|
|
|
|
snd_emux_init_seq(emu, card, index);
|
|
|
|
#ifdef CONFIG_SND_SEQUENCER_OSS
|
|
|
|
snd_emux_init_seq_oss(emu);
|
|
|
|
#endif
|
|
|
|
snd_emux_init_virmidi(emu, card);
|
|
|
|
|
|
|
|
#ifdef CONFIG_PROC_FS
|
|
|
|
snd_emux_proc_init(emu, card, index);
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-28 21:13:40 +08:00
|
|
|
EXPORT_SYMBOL(snd_emux_register);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
2005-11-17 21:24:47 +08:00
|
|
|
int snd_emux_free(struct snd_emux *emu)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (! emu)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&emu->voice_lock, flags);
|
|
|
|
if (emu->timer_active)
|
|
|
|
del_timer(&emu->tlist);
|
|
|
|
spin_unlock_irqrestore(&emu->voice_lock, flags);
|
|
|
|
|
|
|
|
#ifdef CONFIG_PROC_FS
|
|
|
|
snd_emux_proc_free(emu);
|
|
|
|
#endif
|
|
|
|
snd_emux_delete_virmidi(emu);
|
|
|
|
#ifdef CONFIG_SND_SEQUENCER_OSS
|
|
|
|
snd_emux_detach_seq_oss(emu);
|
|
|
|
#endif
|
|
|
|
snd_emux_detach_seq(emu);
|
|
|
|
|
|
|
|
snd_emux_delete_hwdep(emu);
|
|
|
|
|
|
|
|
if (emu->sflist)
|
|
|
|
snd_sf_free(emu->sflist);
|
|
|
|
|
|
|
|
kfree(emu->voices);
|
|
|
|
kfree(emu->name);
|
|
|
|
kfree(emu);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(snd_emux_free);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* INIT part
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int __init alsa_emux_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit alsa_emux_exit(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(alsa_emux_init)
|
|
|
|
module_exit(alsa_emux_exit)
|