History

ALSA: fireface: add helper function to parse MIDI messages transmitted by Fireface 400

This is minor code refactoring to add helper function to parse MIDI message bytes in quadlet message.

Takashi Sakamoto committed 3 years ago

Commit aed713b1 parent 4bdcb8d1 file · +20 −27Browse files

Unified · Split

sound/firewire/fireface/ff-protocol-former.c+20−27
@@ -534,6 +534,22 @@ static void ff400_finish_session(struct snd_ff *ff) · 533 unmodified lines
534534 FF400_ISOC_COMM_STOP, &reg, sizeof(reg), 0);
535535 }
536536
537+static void parse_midi_msg(struct snd_ff *ff, u32 quad, unsigned int port)
538+{
539+ struct snd_rawmidi_substream *substream = READ_ONCE(ff->tx_midi_substreams[port]);
540+
541+ if (substream != NULL) {
542+ u8 byte = (quad >> (16 * port)) & 0x000000ff;
543+
544+ snd_rawmidi_receive(substream, &byte, 1);
545+ }
546+}
547+
548+#define FF400_MSG_FLAG_IS_MIDI_PORT_0 0x00000100
549+#define FF400_MSG_MASK_MIDI_PORT_0 0x000000ff
550+#define FF400_MSG_FLAG_IS_MIDI_PORT_1 0x01000000
551+#define FF400_MSG_MASK_MIDI_PORT_1 0x00ff0000
552+
537553 // For Fireface 400, lower 4 bytes of destination address is configured by bit
538554 // flag in quadlet register (little endian) at 0x'0000'801'0051c. Drivers can
539555 // select one of 4 options:
@@ -560,34 +576,11 @@ static void ff400_handle_msg(struct snd_ff *ff, unsigned int offset, const __le3 · 20 unmodified lines
560576
561577 for (i = 0; i < length / 4; i++) {
562578 u32 quad = le32_to_cpu(buf[i]);
563− u8 byte;
564− unsigned int index;
565− struct snd_rawmidi_substream *substream;
566579
567− /* Message in first port. */
568− /*
569− * This value may represent the index of this unit when the same
570− * units are on the same IEEE 1394 bus. This driver doesn't use
571− * it.
572− */
573− index = (quad >> 8) & 0xff;
574− if (index > 0) {
575− substream = READ_ONCE(ff->tx_midi_substreams[0]);
576− if (substream != NULL) {
577− byte = quad & 0xff;
578− snd_rawmidi_receive(substream, &byte, 1);
579− }
580− }
581−
582− /* Message in second port. */
583− index = (quad >> 24) & 0xff;
584− if (index > 0) {
585− substream = READ_ONCE(ff->tx_midi_substreams[1]);
586− if (substream != NULL) {
587− byte = (quad >> 16) & 0xff;
588− snd_rawmidi_receive(substream, &byte, 1);
589− }
590− }
580+ if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_0)
581+ parse_midi_msg(ff, quad, 0);
582+ else if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_1)
583+ parse_midi_msg(ff, quad, 1);
591584 }
592585 }
593586

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t