diff mbox series

[alsa-lib] seq: Add snd_seq_{get|set}_ump_is_midi1() API functions

Message ID 20240807135148.18291-1-tiwai@suse.de
State New
Headers show
Series [alsa-lib] seq: Add snd_seq_{get|set}_ump_is_midi1() API functions | expand

Commit Message

Takashi Iwai Aug. 7, 2024, 1:51 p.m. UTC
Implement the API function calls corresponding to the new sequencer
port flag bit that has been added recently to the kernel.
A UMP MIDI 2.0 device allow to have an optional MIDI 1.0 port while
speaking in MIDI 2.0 protocol for other UMP Groups.  The new seq port
flag indicates that.

This is rather a minor difference, and since ALSA sequencer core
covers the all conversions, usually you don't have to worry about it
at all.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 include/seq.h                   |  2 ++
 include/sound/uapi/asequencer.h |  2 ++
 src/Versions.in.in              |  2 ++
 src/seq/seq.c                   | 29 +++++++++++++++++++++++++++++
 4 files changed, 35 insertions(+)
diff mbox series

Patch

diff --git a/include/seq.h b/include/seq.h
index 4f03df438288..2eee95a643b4 100644
--- a/include/seq.h
+++ b/include/seq.h
@@ -318,6 +318,7 @@  int snd_seq_port_info_get_timestamp_real(const snd_seq_port_info_t *info);
 int snd_seq_port_info_get_timestamp_queue(const snd_seq_port_info_t *info);
 int snd_seq_port_info_get_direction(const snd_seq_port_info_t *info);
 int snd_seq_port_info_get_ump_group(const snd_seq_port_info_t *info);
+int snd_seq_port_info_get_ump_is_midi1(const snd_seq_port_info_t *info);
 
 void snd_seq_port_info_set_client(snd_seq_port_info_t *info, int client);
 void snd_seq_port_info_set_port(snd_seq_port_info_t *info, int port);
@@ -334,6 +335,7 @@  void snd_seq_port_info_set_timestamp_real(snd_seq_port_info_t *info, int realtim
 void snd_seq_port_info_set_timestamp_queue(snd_seq_port_info_t *info, int queue);
 void snd_seq_port_info_set_direction(snd_seq_port_info_t *info, int direction);
 void snd_seq_port_info_set_ump_group(snd_seq_port_info_t *info, int ump_group);
+void snd_seq_port_info_set_ump_is_midi1(snd_seq_port_info_t *info, int is_midi1);
 
 int snd_seq_create_port(snd_seq_t *handle, snd_seq_port_info_t *info);
 int snd_seq_delete_port(snd_seq_t *handle, int port);
diff --git a/include/sound/uapi/asequencer.h b/include/sound/uapi/asequencer.h
index 923dfdddfc76..b3e9df5894af 100644
--- a/include/sound/uapi/asequencer.h
+++ b/include/sound/uapi/asequencer.h
@@ -477,6 +477,8 @@  struct snd_seq_remove_events {
 #define SNDRV_SEQ_PORT_FLG_TIMESTAMP	(1<<1)
 #define SNDRV_SEQ_PORT_FLG_TIME_REAL	(1<<2)
 
+#define SNDRV_SEQ_PORT_FLG_IS_MIDI1	(1<<3)	/* Keep MIDI 1.0 protocol */
+
 /* port direction */
 #define SNDRV_SEQ_PORT_DIR_UNKNOWN	0
 #define SNDRV_SEQ_PORT_DIR_INPUT	1
diff --git a/src/Versions.in.in b/src/Versions.in.in
index 90849277c983..298e610c2099 100644
--- a/src/Versions.in.in
+++ b/src/Versions.in.in
@@ -209,6 +209,8 @@  ALSA_1.2.13 {
     @SYMBOL_PREFIX@snd_seq_queue_tempo_get_tempo_base;
     @SYMBOL_PREFIX@snd_seq_queue_tempo_set_tempo_base;
     @SYMBOL_PREFIX@snd_seq_has_tempo_base;
+    @SYMBOL_PREFIX@snd_seq_port_info_get_ump_is_midi1;
+    @SYMBOL_PREFIX@snd_seq_port_info_set_ump_is_midi1;
 #endif
 #ifdef HAVE_RAWMIDI_SYMS
     @SYMBOL_PREFIX@snd_ump_endpoint_info_clear;
diff --git a/src/seq/seq.c b/src/seq/seq.c
index d0ecedf0838f..347ff45544fa 100644
--- a/src/seq/seq.c
+++ b/src/seq/seq.c
@@ -2431,6 +2431,19 @@  int snd_seq_port_info_get_ump_group(const snd_seq_port_info_t *info)
 	return info->ump_group;
 }
 
+/**
+ * \brief Get the status of the optional MIDI 1.0 port in MIDI 2.0 UMP Endpoint
+ * \param info port_info container
+ * \return 1 if it's an optional MIDI 1.0 port in MIDI 2.0 UMP Endpoint
+ *
+ * \sa snd_seq_get_port_info(), snd_seq_port_info_set_ump_is_midi1()
+ */
+int snd_seq_port_info_get_ump_is_midi1(const snd_seq_port_info_t *info)
+{
+	assert(info);
+	return !!(info->flags & SNDRV_SEQ_PORT_FLG_IS_MIDI1);
+}
+
 /**
  * \brief Set the client id of a port_info container
  * \param info port_info container
@@ -2635,6 +2648,22 @@  void snd_seq_port_info_set_ump_group(snd_seq_port_info_t *info, int ump_group)
 	info->ump_group = ump_group;
 }
 
+/**
+ * \brief Set the optional MIDI 1.0 port in MIDI 2.0 UMP Endpoint
+ * \param info port_info container
+ * \param is_midi1 non-zero for MIDI 1.0 port in MIDI 2.0 EP
+ *
+ * \sa snd_seq_get_port_info(), snd_seq_port_info_get_ump_is_midi1()
+ */
+void snd_seq_port_info_set_ump_is_midi1(snd_seq_port_info_t *info, int is_midi1)
+{
+	assert(info);
+	if (is_midi1)
+		info->flags |= SNDRV_SEQ_PORT_FLG_IS_MIDI1;
+	else
+		info->flags &= ~SNDRV_SEQ_PORT_FLG_IS_MIDI1;
+}
+
 /**
  * \brief create a sequencer port on the current client
  * \param seq sequencer handle