fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / sound / synth / emux / emux_oss.c
index 9792521..3436816 100644 (file)
 #include "emux_voice.h"
 #include <sound/asoundef.h>
 
-static int snd_emux_open_seq_oss(snd_seq_oss_arg_t *arg, void *closure);
-static int snd_emux_close_seq_oss(snd_seq_oss_arg_t *arg);
-static int snd_emux_ioctl_seq_oss(snd_seq_oss_arg_t *arg, unsigned int cmd, unsigned long ioarg);
-static int snd_emux_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, const char __user *buf, int offs, int count);
-static int snd_emux_reset_seq_oss(snd_seq_oss_arg_t *arg);
-static int snd_emux_event_oss_input(snd_seq_event_t *ev, int direct, void *private, int atomic, int hop);
-static void reset_port_mode(snd_emux_port_t *port, int midi_mode);
-static void emuspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd, unsigned char *event, int atomic, int hop);
-static void gusspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd, unsigned char *event, int atomic, int hop);
-static void fake_event(snd_emux_t *emu, snd_emux_port_t *port, int ch, int param, int val, int atomic, int hop);
+static int snd_emux_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure);
+static int snd_emux_close_seq_oss(struct snd_seq_oss_arg *arg);
+static int snd_emux_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd,
+                                 unsigned long ioarg);
+static int snd_emux_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format,
+                                      const char __user *buf, int offs, int count);
+static int snd_emux_reset_seq_oss(struct snd_seq_oss_arg *arg);
+static int snd_emux_event_oss_input(struct snd_seq_event *ev, int direct,
+                                   void *private, int atomic, int hop);
+static void reset_port_mode(struct snd_emux_port *port, int midi_mode);
+static void emuspec_control(struct snd_emux *emu, struct snd_emux_port *port,
+                           int cmd, unsigned char *event, int atomic, int hop);
+static void gusspec_control(struct snd_emux *emu, struct snd_emux_port *port,
+                           int cmd, unsigned char *event, int atomic, int hop);
+static void fake_event(struct snd_emux *emu, struct snd_emux_port *port,
+                      int ch, int param, int val, int atomic, int hop);
 
 /* operators */
-static snd_seq_oss_callback_t oss_callback = {
+static struct snd_seq_oss_callback oss_callback = {
        .owner = THIS_MODULE,
        .open = snd_emux_open_seq_oss,
        .close = snd_emux_close_seq_oss,
@@ -58,13 +64,13 @@ static snd_seq_oss_callback_t oss_callback = {
  */
 
 void
-snd_emux_init_seq_oss(snd_emux_t *emu)
+snd_emux_init_seq_oss(struct snd_emux *emu)
 {
-       snd_seq_oss_reg_t *arg;
-       snd_seq_device_t *dev;
+       struct snd_seq_oss_reg *arg;
+       struct snd_seq_device *dev;
 
        if (snd_seq_device_new(emu->card, 0, SNDRV_SEQ_DEV_ID_OSS,
-                              sizeof(snd_seq_oss_reg_t), &dev) < 0)
+                              sizeof(struct snd_seq_oss_reg), &dev) < 0)
                return;
 
        emu->oss_synth = dev;
@@ -85,7 +91,7 @@ snd_emux_init_seq_oss(snd_emux_t *emu)
  * unregister
  */
 void
-snd_emux_detach_seq_oss(snd_emux_t *emu)
+snd_emux_detach_seq_oss(struct snd_emux *emu)
 {
        if (emu->oss_synth) {
                snd_device_free(emu->card, emu->oss_synth);
@@ -101,20 +107,20 @@ snd_emux_detach_seq_oss(snd_emux_t *emu)
  * open port for OSS sequencer
  */
 static int
-snd_emux_open_seq_oss(snd_seq_oss_arg_t *arg, void *closure)
+snd_emux_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure)
 {
-       snd_emux_t *emu;
-       snd_emux_port_t *p;
-       snd_seq_port_callback_t callback;
+       struct snd_emux *emu;
+       struct snd_emux_port *p;
+       struct snd_seq_port_callback callback;
        char tmpname[64];
 
-       emu = snd_magic_cast(snd_emux_t, closure, return -EINVAL);
+       emu = closure;
        snd_assert(arg != NULL && emu != NULL, return -ENXIO);
 
-       down(&emu->register_mutex);
+       mutex_lock(&emu->register_mutex);
 
        if (!snd_emux_inc_count(emu)) {
-               up(&emu->register_mutex);
+               mutex_unlock(&emu->register_mutex);
                return -EFAULT;
        }
 
@@ -128,7 +134,7 @@ snd_emux_open_seq_oss(snd_seq_oss_arg_t *arg, void *closure)
        if (p == NULL) {
                snd_printk("can't create port\n");
                snd_emux_dec_count(emu);
-               up(&emu->register_mutex);
+               mutex_unlock(&emu->register_mutex);
                return -ENOMEM;
        }
 
@@ -142,7 +148,7 @@ snd_emux_open_seq_oss(snd_seq_oss_arg_t *arg, void *closure)
 
        snd_emux_reset_port(p);
 
-       up(&emu->register_mutex);
+       mutex_unlock(&emu->register_mutex);
        return 0;
 }
 
@@ -153,7 +159,7 @@ snd_emux_open_seq_oss(snd_seq_oss_arg_t *arg, void *closure)
  * reset port mode
  */
 static void
-reset_port_mode(snd_emux_port_t *port, int midi_mode)
+reset_port_mode(struct snd_emux_port *port, int midi_mode)
 {
        if (midi_mode) {
                port->port_mode = SNDRV_EMUX_PORT_MODE_OSS_MIDI;
@@ -173,25 +179,25 @@ reset_port_mode(snd_emux_port_t *port, int midi_mode)
  * close port
  */
 static int
-snd_emux_close_seq_oss(snd_seq_oss_arg_t *arg)
+snd_emux_close_seq_oss(struct snd_seq_oss_arg *arg)
 {
-       snd_emux_t *emu;
-       snd_emux_port_t *p;
+       struct snd_emux *emu;
+       struct snd_emux_port *p;
 
        snd_assert(arg != NULL, return -ENXIO);
-       p = snd_magic_cast(snd_emux_port_t, arg->private_data, return -EINVAL);
+       p = arg->private_data;
        snd_assert(p != NULL, return -ENXIO);
 
        emu = p->emu;
        snd_assert(emu != NULL, return -ENXIO);
 
-       down(&emu->register_mutex);
+       mutex_lock(&emu->register_mutex);
        snd_emux_sounds_off_all(p);
        snd_soundfont_close_check(emu->sflist, SF_CLIENT_NO(p->chset.port));
        snd_seq_event_port_detach(p->chset.client, p->chset.port);
        snd_emux_dec_count(emu);
 
-       up(&emu->register_mutex);
+       mutex_unlock(&emu->register_mutex);
        return 0;
 }
 
@@ -200,15 +206,15 @@ snd_emux_close_seq_oss(snd_seq_oss_arg_t *arg)
  * load patch
  */
 static int
-snd_emux_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format,
+snd_emux_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format,
                            const char __user *buf, int offs, int count)
 {
-       snd_emux_t *emu;
-       snd_emux_port_t *p;
+       struct snd_emux *emu;
+       struct snd_emux_port *p;
        int rc;
 
        snd_assert(arg != NULL, return -ENXIO);
-       p = snd_magic_cast(snd_emux_port_t, arg->private_data, return -EINVAL);
+       p = arg->private_data;
        snd_assert(p != NULL, return -ENXIO);
 
        emu = p->emu;
@@ -218,7 +224,7 @@ snd_emux_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format,
                rc = snd_soundfont_load_guspatch(emu->sflist, buf, count,
                                                 SF_CLIENT_NO(p->chset.port));
        else if (format == SNDRV_OSS_SOUNDFONT_PATCH) {
-               soundfont_patch_info_t patch;
+               struct soundfont_patch_info patch;
                if (count < (int)sizeof(patch))
                        rc = -EINVAL;
                if (copy_from_user(&patch, buf, sizeof(patch)))
@@ -242,13 +248,13 @@ snd_emux_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format,
  * ioctl
  */
 static int
-snd_emux_ioctl_seq_oss(snd_seq_oss_arg_t *arg, unsigned int cmd, unsigned long ioarg)
+snd_emux_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd, unsigned long ioarg)
 {
-       snd_emux_port_t *p;
-       snd_emux_t *emu;
+       struct snd_emux_port *p;
+       struct snd_emux *emu;
 
        snd_assert(arg != NULL, return -ENXIO);
-       p = snd_magic_cast(snd_emux_port_t, arg->private_data, return -EINVAL);
+       p = arg->private_data;
        snd_assert(p != NULL, return -ENXIO);
 
        emu = p->emu;
@@ -273,12 +279,12 @@ snd_emux_ioctl_seq_oss(snd_seq_oss_arg_t *arg, unsigned int cmd, unsigned long i
  * reset device
  */
 static int
-snd_emux_reset_seq_oss(snd_seq_oss_arg_t *arg)
+snd_emux_reset_seq_oss(struct snd_seq_oss_arg *arg)
 {
-       snd_emux_port_t *p;
+       struct snd_emux_port *p;
 
        snd_assert(arg != NULL, return -ENXIO);
-       p = snd_magic_cast(snd_emux_port_t, arg->private_data, return -EINVAL);
+       p = arg->private_data;
        snd_assert(p != NULL, return -ENXIO);
        snd_emux_reset_port(p);
        return 0;
@@ -289,14 +295,14 @@ snd_emux_reset_seq_oss(snd_seq_oss_arg_t *arg)
  * receive raw events: only SEQ_PRIVATE is accepted.
  */
 static int
-snd_emux_event_oss_input(snd_seq_event_t *ev, int direct, void *private_data,
+snd_emux_event_oss_input(struct snd_seq_event *ev, int direct, void *private_data,
                         int atomic, int hop)
 {
-       snd_emux_t *emu;
-       snd_emux_port_t *p;
+       struct snd_emux *emu;
+       struct snd_emux_port *p;
        unsigned char cmd, *data;
 
-       p = snd_magic_cast(snd_emux_port_t, private_data, return -EINVAL);
+       p = private_data;
        snd_assert(p != NULL, return -EINVAL);
        emu = p->emu;
        snd_assert(emu != NULL, return -EINVAL);
@@ -320,14 +326,14 @@ snd_emux_event_oss_input(snd_seq_event_t *ev, int direct, void *private_data,
  * OSS/AWE driver specific h/w controls
  */
 static void
-emuspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd,
+emuspec_control(struct snd_emux *emu, struct snd_emux_port *port, int cmd,
                unsigned char *event, int atomic, int hop)
 {
        int voice;
        unsigned short p1;
        short p2;
        int i;
-       snd_midi_channel_t *chan;
+       struct snd_midi_channel *chan;
 
        voice = event[3];
        if (voice < 0 || voice >= port->chset.max_channels)
@@ -339,9 +345,11 @@ emuspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd,
        p2 = *(short *) &event[6];
 
        switch (cmd) {
+#if 0 /* don't do this atomically */
        case _EMUX_OSS_REMOVE_LAST_SAMPLES:
                snd_soundfont_remove_unlocked(emu->sflist);
                break;
+#endif
        case _EMUX_OSS_SEND_EFFECT:
                if (chan)
                        snd_emux_send_effect_oss(port, chan, p1, p2);
@@ -413,14 +421,14 @@ emuspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd,
 #include <linux/ultrasound.h>
 
 static void
-gusspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd,
+gusspec_control(struct snd_emux *emu, struct snd_emux_port *port, int cmd,
                unsigned char *event, int atomic, int hop)
 {
        int voice;
        unsigned short p1;
        short p2;
        int plong;
-       snd_midi_channel_t *chan;
+       struct snd_midi_channel *chan;
 
        if (port->port_mode != SNDRV_EMUX_PORT_MODE_OSS_SYNTH)
                return;
@@ -481,9 +489,9 @@ gusspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd,
  * send an event to midi emulation
  */
 static void
-fake_event(snd_emux_t *emu, snd_emux_port_t *port, int ch, int param, int val, int atomic, int hop)
+fake_event(struct snd_emux *emu, struct snd_emux_port *port, int ch, int param, int val, int atomic, int hop)
 {
-       snd_seq_event_t ev;
+       struct snd_seq_event ev;
        memset(&ev, 0, sizeof(ev));
        ev.type = SNDRV_SEQ_EVENT_CONTROLLER;
        ev.data.control.channel = ch;