.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Line 6 Linux USB driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or |
---|
7 | | - * modify it under the terms of the GNU General Public License as |
---|
8 | | - * published by the Free Software Foundation, version 2. |
---|
9 | | - * |
---|
10 | 6 | */ |
---|
11 | 7 | |
---|
12 | 8 | #include <linux/slab.h> |
---|
13 | 9 | |
---|
14 | 10 | #include "midibuf.h" |
---|
| 11 | + |
---|
15 | 12 | |
---|
16 | 13 | static int midibuf_message_length(unsigned char code) |
---|
17 | 14 | { |
---|
.. | .. |
---|
24 | 21 | |
---|
25 | 22 | message_length = length[(code >> 4) - 8]; |
---|
26 | 23 | } else { |
---|
27 | | - /* |
---|
28 | | - Note that according to the MIDI specification 0xf2 is |
---|
29 | | - the "Song Position Pointer", but this is used by Line 6 |
---|
30 | | - to send sysex messages to the host. |
---|
31 | | - */ |
---|
32 | | - static const int length[] = { -1, 2, -1, 2, -1, -1, 1, 1, 1, 1, |
---|
| 24 | + static const int length[] = { -1, 2, 2, 2, -1, -1, 1, 1, 1, -1, |
---|
33 | 25 | 1, 1, 1, -1, 1, 1 |
---|
34 | 26 | }; |
---|
35 | 27 | message_length = length[code & 0x0f]; |
---|
.. | .. |
---|
129 | 121 | } |
---|
130 | 122 | |
---|
131 | 123 | int line6_midibuf_read(struct midi_buffer *this, unsigned char *data, |
---|
132 | | - int length) |
---|
| 124 | + int length, int read_type) |
---|
133 | 125 | { |
---|
134 | 126 | int bytes_used; |
---|
135 | 127 | int length1, length2; |
---|
.. | .. |
---|
152 | 144 | |
---|
153 | 145 | length1 = this->size - this->pos_read; |
---|
154 | 146 | |
---|
155 | | - /* check MIDI command length */ |
---|
156 | 147 | command = this->buf[this->pos_read]; |
---|
| 148 | + /* |
---|
| 149 | + PODxt always has status byte lower nibble set to 0010, |
---|
| 150 | + when it means to send 0000, so we correct if here so |
---|
| 151 | + that control/program changes come on channel 1 and |
---|
| 152 | + sysex message status byte is correct |
---|
| 153 | + */ |
---|
| 154 | + if (read_type == LINE6_MIDIBUF_READ_RX) { |
---|
| 155 | + if (command == 0xb2 || command == 0xc2 || command == 0xf2) { |
---|
| 156 | + unsigned char fixed = command & 0xf0; |
---|
| 157 | + this->buf[this->pos_read] = fixed; |
---|
| 158 | + command = fixed; |
---|
| 159 | + } |
---|
| 160 | + } |
---|
157 | 161 | |
---|
| 162 | + /* check MIDI command length */ |
---|
158 | 163 | if (command & 0x80) { |
---|
159 | 164 | midi_length = midibuf_message_length(command); |
---|
160 | 165 | this->command_prev = command; |
---|