• Takashi Iwai's avatar
    ALSA: seq: Add UMP support · 46397622
    Takashi Iwai authored
    Starting from this commit, we add the basic support of UMP (Universal
    MIDI Packet) events on ALSA sequencer infrastructure.  The biggest
    change here is that, for transferring UMP packets that are up to 128
    bits, we extend the data payload of ALSA sequencer event record when
    the client is declared to support for the new UMP events.
    
    A new event flag bit, SNDRV_SEQ_EVENT_UMP, is defined and it shall be
    set for the UMP packet events that have the larger payload of 128
    bits, defined as struct snd_seq_ump_event.
    
    For controlling the UMP feature enablement in kernel, a new Kconfig,
    CONFIG_SND_SEQ_UMP is introduced.  The extended event for UMP is
    available only when this Kconfig item is set.  Similarly, the size of
    the internal snd_seq_event_cell also increases (in 4 bytes) when the
    Kconfig item is set.  (But the size increase is effective only for
    32bit architectures; 64bit archs already have padding there.)
    Overall, when CONFIG_SND_SEQ_UMP isn't set, there is no change in the
    event and cell, keeping the old sizes.
    
    For applications that want to access the UMP packets, first of all, a
    sequencer client has to declare the user-protocol to match with the
    latest one via the new SNDRV_SEQ_IOCTL_USER_PVERSION; otherwise it's
    treated as if a legacy client without UMP support.
    
    Then the client can switch to the new UMP mode (MIDI 1.0 or MIDI 2.0)
    with a new field, midi_version, in snd_seq_client_info.  When switched
    to UMP mode (midi_version = 1 or 2), the client can write the UMP
    events with SNDRV_SEQ_EVENT_UMP flag.  For reads, the alignment size
    is changed from snd_seq_event (28 bytes) to snd_seq_ump_event (32
    bytes).  When a UMP sequencer event is delivered to a legacy sequencer
    client, it's ignored or handled as an error.
    
    Conceptually, ALSA sequencer client and port correspond to the UMP
    Endpoint and Group, respectively; each client may have multiple ports
    and each port has the fixed number (16) of channels, total up to 256
    channels.
    
    As of this commit, ALSA sequencer core just sends and receives the UMP
    events as-is from/to clients.  The automatic conversions between the
    legacy events and the new UMP events will be implemented in a later
    patch.
    
    Along with this commit, bump the sequencer protocol version to 1.0.3.
    Reviewed-by: default avatarJaroslav Kysela <perex@perex.cz>
    Link: https://lore.kernel.org/r/20230523075358.9672-26-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
    46397622
seq_clientmgr.c 64.6 KB