This is minor code refactoring to add helper function to parse MIDI message bytes in quadlet message.
Unified · Split
| @@ -534,6 +534,22 @@ static void ff400_finish_session(struct snd_ff *ff) · 533 unmodified lines | |||
| 534 | FF400_ISOC_COMM_STOP, ®, sizeof(reg), 0); | 534 | FF400_ISOC_COMM_STOP, ®, sizeof(reg), 0); |
| 535 | } | 535 | } |
| 536 | 536 | ||
| 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 | |||
| 537 | // For Fireface 400, lower 4 bytes of destination address is configured by bit | 553 | // 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 can | 554 | // 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 same | 582 | else if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_1) |
| 570 | * units are on the same IEEE 1394 bus. This driver doesn't use | 583 | 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 | ||