forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/usb/line6/midibuf.c
....@@ -1,17 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Line 6 Linux USB driver
34 *
45 * 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
- *
106 */
117
128 #include <linux/slab.h>
139
1410 #include "midibuf.h"
11
+
1512
1613 static int midibuf_message_length(unsigned char code)
1714 {
....@@ -24,12 +21,7 @@
2421
2522 message_length = length[(code >> 4) - 8];
2623 } 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,
3325 1, 1, 1, -1, 1, 1
3426 };
3527 message_length = length[code & 0x0f];
....@@ -129,7 +121,7 @@
129121 }
130122
131123 int line6_midibuf_read(struct midi_buffer *this, unsigned char *data,
132
- int length)
124
+ int length, int read_type)
133125 {
134126 int bytes_used;
135127 int length1, length2;
....@@ -152,9 +144,22 @@
152144
153145 length1 = this->size - this->pos_read;
154146
155
- /* check MIDI command length */
156147 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
+ }
157161
162
+ /* check MIDI command length */
158163 if (command & 0x80) {
159164 midi_length = midibuf_message_length(command);
160165 this->command_prev = command;