aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/firewire/tascam/tascam-transaction.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/sound/firewire/tascam/tascam-transaction.c b/sound/firewire/tascam/tascam-transaction.c
index ea88655e7e08..99098aa2391e 100644
--- a/sound/firewire/tascam/tascam-transaction.c
+++ b/sound/firewire/tascam/tascam-transaction.c
@@ -63,17 +63,22 @@ static int fill_message(struct snd_rawmidi_substream *substream, u8 *buf)
63 struct snd_tscm *tscm = substream->rmidi->private_data; 63 struct snd_tscm *tscm = substream->rmidi->private_data;
64 unsigned int port = substream->number; 64 unsigned int port = substream->number;
65 int i, len, consume; 65 int i, len, consume;
66 u8 *label, *msg;
66 u8 status; 67 u8 status;
67 68
68 consume = snd_rawmidi_transmit_peek(substream, buf + 1, 3); 69 /* The first byte is used for label, the rest for MIDI bytes. */
70 label = buf;
71 msg = buf + 1;
72
73 consume = snd_rawmidi_transmit_peek(substream, msg, 3);
69 if (consume == 0) 74 if (consume == 0)
70 return 0; 75 return 0;
71 76
72 /* On exclusive message. */ 77 /* On exclusive message. */
73 if (tscm->on_sysex[port]) { 78 if (tscm->on_sysex[port]) {
74 /* Seek the end of exclusives. */ 79 /* Seek the end of exclusives. */
75 for (i = 1; i < 4 || i < consume; ++i) { 80 for (i = 0; i < consume; ++i) {
76 if (buf[i] == 0xf7) { 81 if (msg[i] == 0xf7) {
77 tscm->on_sysex[port] = false; 82 tscm->on_sysex[port] = false;
78 break; 83 break;
79 } 84 }
@@ -81,27 +86,27 @@ static int fill_message(struct snd_rawmidi_substream *substream, u8 *buf)
81 86
82 /* At the end of exclusive message, use label 0x07. */ 87 /* At the end of exclusive message, use label 0x07. */
83 if (!tscm->on_sysex[port]) { 88 if (!tscm->on_sysex[port]) {
84 consume = i; 89 consume = i + 1;
85 buf[0] = (port << 4) | 0x07; 90 *label = (port << 4) | 0x07;
86 /* During exclusive message, use label 0x04. */ 91 /* During exclusive message, use label 0x04. */
87 } else if (consume == 3) { 92 } else if (consume == 3) {
88 buf[0] = (port << 4) | 0x04; 93 *label = (port << 4) | 0x04;
89 /* We need to fill whole 3 bytes. Go to next change. */ 94 /* We need to fill whole 3 bytes. Go to next change. */
90 } else { 95 } else {
91 consume = 0; 96 consume = 0;
92 } 97 }
93 } else { 98 } else {
94 /* The beginning of exclusives. */ 99 /* The beginning of exclusives. */
95 if (buf[1] == 0xf0) { 100 if (msg[0] == 0xf0) {
96 /* Transfer it in next chance in another condition. */ 101 /* Transfer it in next chance in another condition. */
97 tscm->on_sysex[port] = true; 102 tscm->on_sysex[port] = true;
98 return 0; 103 return 0;
99 } else { 104 } else {
100 /* On running-status. */ 105 /* On running-status. */
101 if ((buf[1] & 0x80) != 0x80) 106 if ((msg[0] & 0x80) != 0x80)
102 status = tscm->running_status[port]; 107 status = tscm->running_status[port];
103 else 108 else
104 status = buf[1]; 109 status = msg[0];
105 110
106 /* Calculate consume bytes. */ 111 /* Calculate consume bytes. */
107 len = calculate_message_bytes(status); 112 len = calculate_message_bytes(status);
@@ -109,13 +114,13 @@ static int fill_message(struct snd_rawmidi_substream *substream, u8 *buf)
109 return 0; 114 return 0;
110 115
111 /* On running-status. */ 116 /* On running-status. */
112 if ((buf[1] & 0x80) != 0x80) { 117 if ((msg[0] & 0x80) != 0x80) {
113 buf[3] = buf[2]; 118 msg[2] = msg[1];
114 buf[2] = buf[1]; 119 msg[1] = msg[0];
115 buf[1] = tscm->running_status[port]; 120 msg[0] = tscm->running_status[port];
116 consume--; 121 consume--;
117 } else { 122 } else {
118 tscm->running_status[port] = buf[1]; 123 tscm->running_status[port] = msg[0];
119 } 124 }
120 125
121 /* Confirm length. */ 126 /* Confirm length. */
@@ -125,7 +130,7 @@ static int fill_message(struct snd_rawmidi_substream *substream, u8 *buf)
125 consume = len; 130 consume = len;
126 } 131 }
127 132
128 buf[0] = (port << 4) | (buf[1] >> 4); 133 *label = (port << 4) | (msg[0] >> 4);
129 } 134 }
130 135
131 return consume; 136 return consume;