]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ALSA: firewire-digi00x: add support of asynchronous transaction for outgoing MIDI...
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 11 Oct 2015 03:30:18 +0000 (12:30 +0900)
committerTakashi Iwai <tiwai@suse.de>
Sun, 11 Oct 2015 16:26:14 +0000 (18:26 +0200)
In previous commit, asynchronous transaction for incoming MIDI messages
from physical controls is supported. The physical controls may be
controlled by receiving MIDI messages at a certain address.

This commit supports asynchronous transaction for this purpose.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/digi00x/digi00x-transaction.c
sound/firewire/digi00x/digi00x.h

index 8bf5ed5e5f3ef1626543b6ddcf5959f845662ca0..554324d8c602189e58efc9aebeac1707c3f5cf97 100644 (file)
@@ -9,6 +9,18 @@
 #include <sound/asound.h>
 #include "digi00x.h"
 
+static int fill_midi_message(struct snd_rawmidi_substream *substream, u8 *buf)
+{
+       int bytes;
+
+       buf[0] = 0x80;
+       bytes = snd_rawmidi_transmit_peek(substream, buf + 1, 2);
+       if (bytes >= 0)
+               buf[3] = 0xc0 | bytes;
+
+       return bytes;
+}
+
 static void handle_midi_control(struct snd_dg00x *dg00x, __be32 *buf,
                                unsigned int length)
 {
@@ -102,15 +114,24 @@ int snd_dg00x_transaction_register(struct snd_dg00x *dg00x)
                return err;
 
        err = snd_dg00x_transaction_reregister(dg00x);
-       if (err < 0) {
-               fw_core_remove_address_handler(&dg00x->async_handler);
-               dg00x->async_handler.address_callback = NULL;
-       }
+       if (err < 0)
+               goto error;
+
+       err = snd_fw_async_midi_port_init(&dg00x->out_control, dg00x->unit,
+                                         DG00X_ADDR_BASE + DG00X_OFFSET_MMC,
+                                         4, fill_midi_message);
+       if (err < 0)
+               goto error;
 
        return err;
+error:
+       fw_core_remove_address_handler(&dg00x->async_handler);
+       dg00x->async_handler.address_callback = NULL;
+       return err;
 }
 
 void snd_dg00x_transaction_unregister(struct snd_dg00x *dg00x)
 {
+       snd_fw_async_midi_port_destroy(&dg00x->out_control);
        fw_core_remove_address_handler(&dg00x->async_handler);
 }
index 630f6aabb909a4f8b65d997d01222ade3df03806..907e739936777c359bf6c93973d7faba09ac68df 100644 (file)
@@ -56,6 +56,7 @@ struct snd_dg00x {
 
        /* For asynchronous MIDI controls. */
        struct snd_rawmidi_substream *in_control;
+       struct snd_fw_async_midi_port out_control;
 };
 
 #define DG00X_ADDR_BASE                0xffffe0000000ull