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
534 FF400_ISOC_COMM_STOP, &reg, sizeof(reg), 0);534 FF400_ISOC_COMM_STOP, &reg, sizeof(reg), 0);
535}535}
536 536
537static 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
537// For Fireface 400, lower 4 bytes of destination address is configured by bit553// For Fireface 400, lower 4 bytes of destination address is configured by bit
538// flag in quadlet register (little endian) at 0x'0000'801'0051c. Drivers can554// flag in quadlet register (little endian) at 0x'0000'801'0051c. Drivers can
539// select one of 4 options:555// 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
560 576
561 for (i = 0; i < length / 4; i++) {577 for (i = 0; i < length / 4; i++) {
562 u32 quad = le32_to_cpu(buf[i]);578 u32 quad = le32_to_cpu(buf[i]);
563 u8 byte;
564 unsigned int index;
565 struct snd_rawmidi_substream *substream;
566 579
567 /* Message in first port. */580 if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_0)
568 /*581 parse_midi_msg(ff, quad, 0);
569 * This value may represent the index of this unit when the same582 else if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_1)
570 * units are on the same IEEE 1394 bus. This driver doesn't use583 parse_midi_msg(ff, quad, 1);
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 }
591 }584 }
592}585}
593 586

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