]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: fireface: localize a handler for MIDI messages on tx transaction
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Tue, 11 Dec 2018 10:17:34 +0000 (19:17 +0900)
committerTakashi Iwai <tiwai@suse.de>
Tue, 11 Dec 2018 13:57:38 +0000 (14:57 +0100)
Content of asynchronous transaction for MIDI messages differs between
Fireface 400 and 800.

This commit adds a model-specific handler for the transaction and adds
arrangement.

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

index b283762e785c224b185568e7f59c1e1ece3f5aaf..8f34174ee81354922136dd03e055e9646c322e0c 100644 (file)
@@ -105,7 +105,45 @@ static int ff400_switch_fetching_mode(struct snd_ff *ff, bool enable)
        return err;
 }
 
+static void ff400_handle_midi_msg(struct snd_ff *ff, __le32 *buf, size_t length)
+{
+       int i;
+
+       for (i = 0; i < length / 4; i++) {
+               u32 quad = le32_to_cpu(buf[i]);
+               u8 byte;
+               unsigned int index;
+               struct snd_rawmidi_substream *substream;
+
+               /* Message in first port. */
+               /*
+                * This value may represent the index of this unit when the same
+                * units are on the same IEEE 1394 bus. This driver doesn't use
+                * it.
+                */
+               index = (quad >> 8) & 0xff;
+               if (index > 0) {
+                       substream = READ_ONCE(ff->tx_midi_substreams[0]);
+                       if (substream != NULL) {
+                               byte = quad & 0xff;
+                               snd_rawmidi_receive(substream, &byte, 1);
+                       }
+               }
+
+               /* Message in second port. */
+               index = (quad >> 24) & 0xff;
+               if (index > 0) {
+                       substream = READ_ONCE(ff->tx_midi_substreams[1]);
+                       if (substream != NULL) {
+                               byte = (quad >> 16) & 0xff;
+                               snd_rawmidi_receive(substream, &byte, 1);
+                       }
+               }
+       }
+}
+
 const struct snd_ff_protocol snd_ff_protocol_ff400 = {
+       .handle_midi_msg        = ff400_handle_midi_msg,
        .begin_session          = ff400_begin_session,
        .finish_session         = ff400_finish_session,
        .switch_fetching_mode   = ff400_switch_fetching_mode,
index 1ce4cef6ca358897bf57d52a1a0de305ba7bf0b4..d8768348067ba27896d12b2e113bde8a0dff1e5a 100644 (file)
@@ -206,42 +206,10 @@ static void handle_midi_msg(struct fw_card *card, struct fw_request *request,
 {
        struct snd_ff *ff = callback_data;
        __le32 *buf = data;
-       u32 quad;
-       u8 byte;
-       unsigned int index;
-       struct snd_rawmidi_substream *substream;
-       int i;
 
        fw_send_response(card, request, RCODE_COMPLETE);
 
-       for (i = 0; i < length / 4; i++) {
-               quad = le32_to_cpu(buf[i]);
-
-               /* Message in first port. */
-               /*
-                * This value may represent the index of this unit when the same
-                * units are on the same IEEE 1394 bus. This driver doesn't use
-                * it.
-                */
-               index = (quad >> 8) & 0xff;
-               if (index > 0) {
-                       substream = READ_ONCE(ff->tx_midi_substreams[0]);
-                       if (substream != NULL) {
-                               byte = quad & 0xff;
-                               snd_rawmidi_receive(substream, &byte, 1);
-                       }
-               }
-
-               /* Message in second port. */
-               index = (quad >> 24) & 0xff;
-               if (index > 0) {
-                       substream = READ_ONCE(ff->tx_midi_substreams[1]);
-                       if (substream != NULL) {
-                               byte = (quad >> 16) & 0xff;
-                               snd_rawmidi_receive(substream, &byte, 1);
-                       }
-               }
-       }
+       ff->spec->protocol->handle_midi_msg(ff, buf, length);
 }
 
 static int allocate_own_address(struct snd_ff *ff, int i)
index 466304c72d7661d08ad6a143a89e46ef663e2905..178a96cb6e2a770f2e5f62e9dfd1d1467ccc5088 100644 (file)
@@ -108,6 +108,7 @@ enum snd_ff_clock_src {
 };
 
 struct snd_ff_protocol {
+       void (*handle_midi_msg)(struct snd_ff *ff, __le32 *buf, size_t length);
        int (*begin_session)(struct snd_ff *ff, unsigned int rate);
        void (*finish_session)(struct snd_ff *ff);
        int (*switch_fetching_mode)(struct snd_ff *ff, bool enable);