mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 06:01:57 +00:00
46397622a3
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: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20230523075358.9672-26-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
76 lines
3.1 KiB
C
76 lines
3.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Main header file for the ALSA sequencer
|
|
* Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
|
|
* (c) 1998-1999 by Jaroslav Kysela <perex@perex.cz>
|
|
*/
|
|
#ifndef __SOUND_ASEQUENCER_H
|
|
#define __SOUND_ASEQUENCER_H
|
|
|
|
#include <linux/ioctl.h>
|
|
#include <sound/asound.h>
|
|
#include <uapi/sound/asequencer.h>
|
|
|
|
/* helper macro */
|
|
#define snd_seq_event_bounce_ext_data(ev) ((void*)((char *)(ev)->data.ext.ptr + sizeof(struct snd_seq_event_bounce)))
|
|
|
|
/*
|
|
* type check macros
|
|
*/
|
|
/* result events: 0-4 */
|
|
#define snd_seq_ev_is_result_type(ev) ((ev)->type < 5)
|
|
/* channel specific events: 5-19 */
|
|
#define snd_seq_ev_is_channel_type(ev) ((ev)->type >= 5 && (ev)->type < 20)
|
|
/* note events: 5-9 */
|
|
#define snd_seq_ev_is_note_type(ev) ((ev)->type >= 5 && (ev)->type < 10)
|
|
/* control events: 10-19 */
|
|
#define snd_seq_ev_is_control_type(ev) ((ev)->type >= 10 && (ev)->type < 20)
|
|
/* queue control events: 30-39 */
|
|
#define snd_seq_ev_is_queue_type(ev) ((ev)->type >= 30 && (ev)->type < 40)
|
|
/* system status messages */
|
|
#define snd_seq_ev_is_message_type(ev) ((ev)->type >= 60 && (ev)->type < 69)
|
|
/* sample messages */
|
|
#define snd_seq_ev_is_sample_type(ev) ((ev)->type >= 70 && (ev)->type < 79)
|
|
/* user-defined messages */
|
|
#define snd_seq_ev_is_user_type(ev) ((ev)->type >= 90 && (ev)->type < 99)
|
|
/* fixed length events: 0-99 */
|
|
#define snd_seq_ev_is_fixed_type(ev) ((ev)->type < 100)
|
|
/* variable length events: 130-139 */
|
|
#define snd_seq_ev_is_variable_type(ev) ((ev)->type >= 130 && (ev)->type < 140)
|
|
/* reserved for kernel */
|
|
#define snd_seq_ev_is_reserved(ev) ((ev)->type >= 150)
|
|
|
|
/* direct dispatched events */
|
|
#define snd_seq_ev_is_direct(ev) ((ev)->queue == SNDRV_SEQ_QUEUE_DIRECT)
|
|
|
|
/*
|
|
* macros to check event flags
|
|
*/
|
|
/* prior events */
|
|
#define snd_seq_ev_is_prior(ev) (((ev)->flags & SNDRV_SEQ_PRIORITY_MASK) == SNDRV_SEQ_PRIORITY_HIGH)
|
|
|
|
/* event length type */
|
|
#define snd_seq_ev_length_type(ev) ((ev)->flags & SNDRV_SEQ_EVENT_LENGTH_MASK)
|
|
#define snd_seq_ev_is_fixed(ev) (snd_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_FIXED)
|
|
#define snd_seq_ev_is_variable(ev) (snd_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_VARIABLE)
|
|
#define snd_seq_ev_is_varusr(ev) (snd_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_VARUSR)
|
|
|
|
/* time-stamp type */
|
|
#define snd_seq_ev_timestamp_type(ev) ((ev)->flags & SNDRV_SEQ_TIME_STAMP_MASK)
|
|
#define snd_seq_ev_is_tick(ev) (snd_seq_ev_timestamp_type(ev) == SNDRV_SEQ_TIME_STAMP_TICK)
|
|
#define snd_seq_ev_is_real(ev) (snd_seq_ev_timestamp_type(ev) == SNDRV_SEQ_TIME_STAMP_REAL)
|
|
|
|
/* time-mode type */
|
|
#define snd_seq_ev_timemode_type(ev) ((ev)->flags & SNDRV_SEQ_TIME_MODE_MASK)
|
|
#define snd_seq_ev_is_abstime(ev) (snd_seq_ev_timemode_type(ev) == SNDRV_SEQ_TIME_MODE_ABS)
|
|
#define snd_seq_ev_is_reltime(ev) (snd_seq_ev_timemode_type(ev) == SNDRV_SEQ_TIME_MODE_REL)
|
|
|
|
/* check whether the given event is a UMP event */
|
|
#define snd_seq_ev_is_ump(ev) \
|
|
(IS_ENABLED(CONFIG_SND_SEQ_UMP) && ((ev)->flags & SNDRV_SEQ_EVENT_UMP))
|
|
|
|
/* queue sync port */
|
|
#define snd_seq_queue_sync_port(q) ((q) + 16)
|
|
|
|
#endif /* __SOUND_ASEQUENCER_H */
|