2019-05-27 06:55:05 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Main header file for the ALSA sequencer
|
|
|
|
* Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
|
2007-10-15 07:50:19 +00:00
|
|
|
* (c) 1998-1999 by Jaroslav Kysela <perex@perex.cz>
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
#ifndef __SOUND_ASEQUENCER_H
|
|
|
|
#define __SOUND_ASEQUENCER_H
|
|
|
|
|
|
|
|
#include <linux/ioctl.h>
|
|
|
|
#include <sound/asound.h>
|
2012-10-09 08:49:13 +00:00
|
|
|
#include <uapi/sound/asequencer.h>
|
2005-11-17 13:04:02 +00:00
|
|
|
|
|
|
|
/* helper macro */
|
|
|
|
#define snd_seq_event_bounce_ext_data(ev) ((void*)((char *)(ev)->data.ext.ptr + sizeof(struct snd_seq_event_bounce)))
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* type check macros
|
|
|
|
*/
|
|
|
|
/* result events: 0-4 */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_result_type(ev) ((ev)->type < 5)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* channel specific events: 5-19 */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_channel_type(ev) ((ev)->type >= 5 && (ev)->type < 20)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* note events: 5-9 */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_note_type(ev) ((ev)->type >= 5 && (ev)->type < 10)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* control events: 10-19 */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_control_type(ev) ((ev)->type >= 10 && (ev)->type < 20)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* queue control events: 30-39 */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_queue_type(ev) ((ev)->type >= 30 && (ev)->type < 40)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* system status messages */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_message_type(ev) ((ev)->type >= 60 && (ev)->type < 69)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* sample messages */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_sample_type(ev) ((ev)->type >= 70 && (ev)->type < 79)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* user-defined messages */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_user_type(ev) ((ev)->type >= 90 && (ev)->type < 99)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* fixed length events: 0-99 */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_fixed_type(ev) ((ev)->type < 100)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* variable length events: 130-139 */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_variable_type(ev) ((ev)->type >= 130 && (ev)->type < 140)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* reserved for kernel */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_reserved(ev) ((ev)->type >= 150)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* direct dispatched events */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_direct(ev) ((ev)->queue == SNDRV_SEQ_QUEUE_DIRECT)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* macros to check event flags
|
|
|
|
*/
|
|
|
|
/* prior events */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_ev_is_prior(ev) (((ev)->flags & SNDRV_SEQ_PRIORITY_MASK) == SNDRV_SEQ_PRIORITY_HIGH)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* event length type */
|
2005-11-17 13:04:02 +00:00
|
|
|
#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)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* time-stamp type */
|
2005-11-17 13:04:02 +00:00
|
|
|
#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)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* time-mode type */
|
2005-11-17 13:04:02 +00:00
|
|
|
#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)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
ALSA: seq: Add UMP support
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>
2023-05-23 07:53:46 +00:00
|
|
|
/* 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))
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* queue sync port */
|
2005-11-17 13:04:02 +00:00
|
|
|
#define snd_seq_queue_sync_port(q) ((q) + 16)
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* __SOUND_ASEQUENCER_H */
|