]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ALSA: firewire-tascam: move message parameters for async midi port
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Fri, 14 Apr 2017 07:46:31 +0000 (16:46 +0900)
committerTakashi Iwai <tiwai@suse.de>
Fri, 14 Apr 2017 12:50:40 +0000 (14:50 +0200)
Units on TASCAM FireWire series handle MIDI messages with support for
running status. Drivers for the series should remember current running
status and transfer valid MIDI messages. For this purpose, current
ALSA driver for the series has some members in its top-level structure.
This is due to better abstraction of async midi port. Nowadays, the
abstraction was localized just for the driver.

This commit moves the members to structure for async midi port.

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

index 901df81129bbf83491cf4bea550784017774feef..760f72a86c2704df87ced3377fd2e33480e1fa4c 100644 (file)
@@ -20,9 +20,6 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream)
 
        snd_fw_async_midi_port_init(&tscm->out_ports[substream->number]);
 
-       /* Initialize internal status. */
-       tscm->running_status[substream->number] = 0;
-       tscm->on_sysex[substream->number] = 0;
        return 0;
 }
 
index a248a4ae0353f794bd7a7432edcc8c3282973998..8967c52f503284a2d610352fcc7324a53a088b6d 100644 (file)
@@ -58,39 +58,38 @@ static inline int calculate_message_bytes(u8 status)
        return -EINVAL;
 }
 
-static int fill_message(struct snd_rawmidi_substream *substream, u8 *buf)
+static int fill_message(struct snd_fw_async_midi_port *port,
+                       struct snd_rawmidi_substream *substream)
 {
-       struct snd_tscm *tscm = substream->rmidi->private_data;
-       unsigned int port = substream->number;
        int i, len, consume;
        u8 *label, *msg;
        u8 status;
 
        /* The first byte is used for label, the rest for MIDI bytes. */
-       label = buf;
-       msg = buf + 1;
+       label = port->buf;
+       msg = port->buf + 1;
 
        consume = snd_rawmidi_transmit_peek(substream, msg, 3);
        if (consume == 0)
                return 0;
 
        /* On exclusive message. */
-       if (tscm->on_sysex[port]) {
+       if (port->on_sysex) {
                /* Seek the end of exclusives. */
                for (i = 0; i < consume; ++i) {
                        if (msg[i] == 0xf7) {
-                               tscm->on_sysex[port] = false;
+                               port->on_sysex = false;
                                break;
                        }
                }
 
                /* At the end of exclusive message, use label 0x07. */
-               if (!tscm->on_sysex[port]) {
+               if (!port->on_sysex) {
                        consume = i + 1;
-                       *label = (port << 4) | 0x07;
+                       *label = (substream->number << 4) | 0x07;
                /* During exclusive message, use label 0x04. */
                } else if (consume == 3) {
-                       *label = (port << 4) | 0x04;
+                       *label = (substream->number << 4) | 0x04;
                /* We need to fill whole 3 bytes. Go to next change. */
                } else {
                        return 0;
@@ -101,12 +100,12 @@ static int fill_message(struct snd_rawmidi_substream *substream, u8 *buf)
                /* The beginning of exclusives. */
                if (msg[0] == 0xf0) {
                        /* Transfer it in next chance in another condition. */
-                       tscm->on_sysex[port] = true;
+                       port->on_sysex = true;
                        return 0;
                } else {
                        /* On running-status. */
                        if ((msg[0] & 0x80) != 0x80)
-                               status = tscm->running_status[port];
+                               status = port->running_status;
                        else
                                status = msg[0];
 
@@ -124,18 +123,18 @@ static int fill_message(struct snd_rawmidi_substream *substream, u8 *buf)
 
                                msg[2] = msg[1];
                                msg[1] = msg[0];
-                               msg[0] = tscm->running_status[port];
+                               msg[0] = port->running_status;
                        } else {
                                /* Enough MIDI bytes were not retrieved. */
                                if (consume < len)
                                        return 0;
                                consume = len;
 
-                               tscm->running_status[port] = msg[0];
+                               port->running_status = msg[0];
                        }
                }
 
-               *label = (port << 4) | (msg[0] >> 4);
+               *label = (substream->number << 4) | (msg[0] >> 4);
        }
 
        if (len > 0 && len < 3)
@@ -196,7 +195,7 @@ static void midi_port_work(struct work_struct *work)
         * Later, snd_rawmidi_transmit_ack() is called.
         */
        memset(port->buf, 0, 4);
-       port->consume_bytes = fill_message(substream, port->buf);
+       port->consume_bytes = fill_message(port, substream);
        if (port->consume_bytes <= 0) {
                /* Do it in next chance, immediately. */
                if (port->consume_bytes == 0) {
@@ -240,6 +239,8 @@ void snd_fw_async_midi_port_init(struct snd_fw_async_midi_port *port)
 {
        port->idling = true;
        port->error = false;
+       port->running_status = 0;
+       port->on_sysex = false;
 }
 
 static void handle_midi_tx(struct fw_card *card, struct fw_request *request,
index 37ec2016d0332dd13fffd35bcf1459757bcc7268..08ecfae5c5840aa3082b85c1ed588f2d323ab4df 100644 (file)
@@ -55,6 +55,8 @@ struct snd_fw_async_midi_port {
        struct fw_transaction transaction;
 
        u8 buf[4];
+       u8 running_status;
+       bool on_sysex;
 
        struct snd_rawmidi_substream *substream;
        int consume_bytes;
@@ -87,8 +89,6 @@ struct snd_tscm {
 
        /* For MIDI message outgoing transactions. */
        struct snd_fw_async_midi_port out_ports[TSCM_MIDI_OUT_PORT_MAX];
-       u8 running_status[TSCM_MIDI_OUT_PORT_MAX];
-       bool on_sysex[TSCM_MIDI_OUT_PORT_MAX];
 };
 
 #define TSCM_ADDR_BASE                 0xffff00000000ull