2019-05-26 23:55:05 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
|
|
|
|
*
|
|
|
|
* Routines for control of EMU WaveTable chip
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/wait.h>
|
|
|
|
#include <linux/slab.h>
|
2005-06-23 00:09:02 -07:00
|
|
|
#include <linux/string.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/emux_synth.h>
|
|
|
|
#include <linux/init.h>
|
2011-07-15 09:38:28 -07:00
|
|
|
#include <linux/module.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#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 06:24:47 -07:00
|
|
|
int snd_emux_new(struct snd_emux **remu)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2005-11-17 06:24:47 -07:00
|
|
|
struct snd_emux *emu;
|
2005-04-16 15:20:36 -07: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 05:22:34 -07:00
|
|
|
emu = kzalloc(sizeof(*emu), GFP_KERNEL);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (emu == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
spin_lock_init(&emu->voice_lock);
|
2006-01-16 08:31:42 -07:00
|
|
|
mutex_init(&emu->register_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
emu->client = -1;
|
2017-06-09 05:06:46 -07:00
|
|
|
#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
|
2005-04-16 15:20:36 -07:00
|
|
|
emu->oss_synth = NULL;
|
|
|
|
#endif
|
|
|
|
emu->max_voices = 0;
|
|
|
|
emu->use_time = 0;
|
|
|
|
|
2017-10-24 08:34:40 -07:00
|
|
|
timer_setup(&emu->tlist, snd_emux_timer_callback, 0);
|
2005-04-16 15:20:36 -07:00
|
|
|
emu->timer_active = 0;
|
|
|
|
|
|
|
|
*remu = emu;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-28 06:13:40 -07:00
|
|
|
EXPORT_SYMBOL(snd_emux_new);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
2005-11-17 06:24:47 -07: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 02:50:13 -07:00
|
|
|
{
|
2005-11-17 06:24:47 -07:00
|
|
|
struct snd_emux *emu = private_data;
|
2005-11-17 02:50:13 -07:00
|
|
|
return emu->ops.sample_new(emu, sp, hdr, buf, count);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-11-17 06:24:47 -07:00
|
|
|
static int sf_sample_free(void *private_data, struct snd_sf_sample *sp,
|
|
|
|
struct snd_util_memhdr *hdr)
|
2005-11-17 02:50:13 -07:00
|
|
|
{
|
2005-11-17 06:24:47 -07:00
|
|
|
struct snd_emux *emu = private_data;
|
2005-11-17 02:50:13 -07:00
|
|
|
return emu->ops.sample_free(emu, sp, hdr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sf_sample_reset(void *private_data)
|
|
|
|
{
|
2005-11-17 06:24:47 -07:00
|
|
|
struct snd_emux *emu = private_data;
|
2005-11-17 02:50:13 -07:00
|
|
|
emu->ops.sample_reset(emu);
|
|
|
|
}
|
|
|
|
|
2005-11-17 06:24:47 -07:00
|
|
|
int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, char *name)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
int err;
|
2005-11-17 06:24:47 -07:00
|
|
|
struct snd_sf_callback sf_cb;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-08-08 08:12:47 -07:00
|
|
|
if (snd_BUG_ON(!emu->hw || emu->max_voices <= 0))
|
|
|
|
return -EINVAL;
|
|
|
|
if (snd_BUG_ON(!card || !name))
|
|
|
|
return -EINVAL;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
emu->card = card;
|
2024-01-20 02:42:12 -07:00
|
|
|
emu->name = kstrdup_const(name, GFP_KERNEL);
|
2005-11-17 06:24:47 -07:00
|
|
|
emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice),
|
|
|
|
GFP_KERNEL);
|
2021-11-08 17:37:42 -07:00
|
|
|
if (emu->name == NULL || emu->voices == NULL)
|
2005-04-16 15:20:36 -07:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/* create soundfont list */
|
|
|
|
memset(&sf_cb, 0, sizeof(sf_cb));
|
|
|
|
sf_cb.private_data = emu;
|
2024-04-05 23:48:30 -07:00
|
|
|
sf_cb.sample_new = sf_sample_new;
|
|
|
|
sf_cb.sample_free = sf_sample_free;
|
2005-11-17 02:50:13 -07:00
|
|
|
if (emu->ops.sample_reset)
|
|
|
|
sf_cb.sample_reset = sf_sample_reset;
|
2005-04-16 15:20:36 -07:00
|
|
|
emu->sflist = snd_sf_new(&sf_cb, emu->memhdr);
|
|
|
|
if (emu->sflist == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2021-06-08 07:05:37 -07:00
|
|
|
err = snd_emux_init_hwdep(emu);
|
|
|
|
if (err < 0)
|
2005-04-16 15:20:36 -07:00
|
|
|
return err;
|
|
|
|
|
|
|
|
snd_emux_init_voices(emu);
|
|
|
|
|
|
|
|
snd_emux_init_seq(emu, card, index);
|
2017-06-09 05:06:46 -07:00
|
|
|
#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
|
2005-04-16 15:20:36 -07:00
|
|
|
snd_emux_init_seq_oss(emu);
|
|
|
|
#endif
|
|
|
|
snd_emux_init_virmidi(emu, card);
|
|
|
|
|
|
|
|
snd_emux_proc_init(emu, card, index);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-28 06:13:40 -07:00
|
|
|
EXPORT_SYMBOL(snd_emux_register);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
2005-11-17 06:24:47 -07:00
|
|
|
int snd_emux_free(struct snd_emux *emu)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
if (! emu)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2022-12-20 11:45:19 -07:00
|
|
|
timer_shutdown_sync(&emu->tlist);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
snd_emux_proc_free(emu);
|
|
|
|
snd_emux_delete_virmidi(emu);
|
2017-06-09 05:06:46 -07:00
|
|
|
#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
|
2005-04-16 15:20:36 -07:00
|
|
|
snd_emux_detach_seq_oss(emu);
|
|
|
|
#endif
|
|
|
|
snd_emux_detach_seq(emu);
|
|
|
|
snd_emux_delete_hwdep(emu);
|
2015-01-03 10:28:21 -07:00
|
|
|
snd_sf_free(emu->sflist);
|
2005-04-16 15:20:36 -07:00
|
|
|
kfree(emu->voices);
|
2024-01-20 02:42:12 -07:00
|
|
|
kfree_const(emu->name);
|
2005-04-16 15:20:36 -07:00
|
|
|
kfree(emu);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(snd_emux_free);
|