Update of /cvsroot/alsa/alsa-kernel/synth/emux
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19892/alsa-kernel/synth/emux
Modified Files:
Makefile emux.c emux_seq.c emux_voice.h soundfont.c
Added Files:
emux_hwdep.c
Log Message:
- added the support of hwdep for EmuX WaveTable on emu10k1 and sbawe.
SoundFont can be loaded via the ALSA native hwdep device now.
--- NEW FILE: emux_hwdep.c ---
/*
* Interface for hwdep device
*
* Copyright (C) 2004 Takashi Iwai <[EMAIL PROTECTED]>
*
* 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 <sound/core.h>
#include <sound/hwdep.h>
#include <asm/uaccess.h>
#include "emux_voice.h"
/*
* open the hwdep device
*/
static int
snd_emux_hwdep_open(snd_hwdep_t *hw, struct file *file)
{
return 0;
}
/*
* close the device
*/
static int
snd_emux_hwdep_release(snd_hwdep_t *hw, struct file *file)
{
return 0;
}
#define TMP_CLIENT_ID 0x1001
/*
* load patch
*/
static int
snd_emux_hwdep_load_patch(snd_emux_t *emu, void __user *arg)
{
int err;
soundfont_patch_info_t patch;
if (copy_from_user(&patch, arg, sizeof(patch)))
return -EFAULT;
if (patch.type >= SNDRV_SFNT_LOAD_INFO &&
patch.type <= SNDRV_SFNT_PROBE_DATA) {
err = snd_soundfont_load(emu->sflist, arg, patch.len + sizeof(patch),
TMP_CLIENT_ID);
if (err < 0)
return err;
} else {
if (emu->ops.load_fx)
return emu->ops.load_fx(emu, patch.type, patch.optarg, arg,
patch.len + sizeof(patch));
else
return -EINVAL;
}
return 0;
}
/*
* set misc mode
*/
static int
snd_emux_hwdep_misc_mode(snd_emux_t *emu, void __user *arg)
{
struct sndrv_emux_misc_mode info;
int i;
if (copy_from_user(&info, arg, sizeof(info)))
return -EFAULT;
if (info.mode < 0 || info.mode >= EMUX_MD_END)
return -EINVAL;
if (info.port < 0) {
for (i = 0; i < emu->num_ports; i++)
emu->portptrs[i]->ctrls[info.mode] = info.value;
} else {
if (info.port < emu->num_ports)
emu->portptrs[info.port]->ctrls[info.mode] = info.value;
}
return 0;
}
/*
* ioctl
*/
static int
snd_emux_hwdep_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cmd, unsigned
long arg)
{
snd_emux_t *emu = snd_magic_cast(snd_emux_t, hw->private_data, return -ENXIO);
switch (cmd) {
case SNDRV_EMUX_IOCTL_VERSION:
return put_user(SNDRV_EMUX_VERSION, (unsigned int __user *)arg);
case SNDRV_EMUX_IOCTL_LOAD_PATCH:
return snd_emux_hwdep_load_patch(emu, (void __user *)arg);
case SNDRV_EMUX_IOCTL_RESET_SAMPLES:
snd_soundfont_remove_samples(emu->sflist);
break;
case SNDRV_EMUX_IOCTL_REMOVE_LAST_SAMPLES:
snd_soundfont_remove_unlocked(emu->sflist);
break;
case SNDRV_EMUX_IOCTL_MEM_AVAIL:
if (emu->memhdr) {
int size = snd_util_mem_avail(emu->memhdr);
return put_user(size, (unsigned int __user *)arg);
}
break;
case SNDRV_EMUX_IOCTL_MISC_MODE:
return snd_emux_hwdep_misc_mode(emu, (void __user *)arg);
}
return 0;
}
/*
* register hwdep device
*/
int
snd_emux_init_hwdep(snd_emux_t *emu)
{
snd_hwdep_t *hw;
int err;
if ((err = snd_hwdep_new(emu->card, SNDRV_EMUX_HWDEP_NAME, emu->hwdep_idx,
&hw)) < 0)
return err;
emu->hwdep = hw;
strcpy(hw->name, SNDRV_EMUX_HWDEP_NAME);
hw->iface = SNDRV_HWDEP_IFACE_EMUX_WAVETABLE;
hw->ops.open = snd_emux_hwdep_open;
hw->ops.release = snd_emux_hwdep_release;
hw->ops.ioctl = snd_emux_hwdep_ioctl;
hw->exclusive = 1;
hw->private_data = emu;
if ((err = snd_card_register(emu->card)) < 0)
return err;
return 0;
}
/*
* unregister
*/
void
snd_emux_delete_hwdep(snd_emux_t *emu)
{
if (emu->hwdep) {
snd_device_free(emu->card, emu->hwdep);
emu->hwdep = NULL;
}
}
Index: Makefile
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/synth/emux/Makefile,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Makefile 9 Feb 2003 18:41:57 -0000 1.12
+++ Makefile 26 Jan 2004 10:49:37 -0000 1.13
@@ -4,7 +4,7 @@
#
snd-emux-synth-objs := emux.o emux_synth.o emux_seq.o emux_nrpn.o \
- emux_effect.o emux_proc.o soundfont.o \
+ emux_effect.o emux_proc.o emux_hwdep.o soundfont.o \
$(if $(CONFIG_SND_SEQUENCER_OSS),emux_oss.o)
#
Index: emux.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/synth/emux/emux.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- emux.c 23 Nov 2002 10:41:54 -0000 1.9
+++ emux.c 26 Jan 2004 10:49:37 -0000 1.10
@@ -67,6 +67,7 @@
*/
int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name)
{
+ int err;
snd_sf_callback_t sf_cb;
snd_assert(emu->hw != NULL, return -EINVAL);
@@ -90,6 +91,9 @@
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);
@@ -128,6 +132,8 @@
#endif
snd_emux_detach_seq(emu);
+ snd_emux_delete_hwdep(emu);
+
if (emu->sflist)
snd_sf_free(emu->sflist);
Index: emux_seq.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/synth/emux/emux_seq.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- emux_seq.c 28 Feb 2003 15:08:26 -0000 1.9
+++ emux_seq.c 26 Jan 2004 10:49:37 -0000 1.10
@@ -107,6 +107,7 @@
p->port_mode = SNDRV_EMUX_PORT_MODE_MIDI;
snd_emux_init_port(p);
emu->ports[i] = p->chset.port;
+ emu->portptrs[i] = p;
}
return 0;
Index: emux_voice.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/synth/emux/emux_voice.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- emux_voice.h 14 Feb 2002 17:40:34 -0000 1.4
+++ emux_voice.h 26 Jan 2004 10:49:37 -0000 1.5
@@ -81,4 +81,8 @@
#define STATE_IS_PLAYING(s) ((s) & SNDRV_EMUX_ST_ON)
+/* emux_hwdep.c */
+int snd_emux_init_hwdep(snd_emux_t *emu);
+void snd_emux_delete_hwdep(snd_emux_t *emu);
+
#endif
Index: soundfont.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/synth/emux/soundfont.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- soundfont.c 16 Jan 2004 18:02:40 -0000 1.9
+++ soundfont.c 26 Jan 2004 10:49:37 -0000 1.10
@@ -30,6 +30,7 @@
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/soundfont.h>
+#include <sound/seq_oss_legacy.h>
/* Prototypes for static functions */
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog