diff mbox series

[alsa-lib,v2,06/10] control: Add UMP Endpoint and Block info query support

Message ID 20230523122247.11744-7-tiwai@suse.de (mailing list archive)
State New, archived
Headers show
Series Add MIDI 2.0 support | expand

Commit Message

Takashi Iwai May 23, 2023, 12:22 p.m. UTC
Add functions to query the UMP Endpoint and Block info via control
interface.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 include/control.h           |  2 ++
 include/local.h             |  1 +
 src/Versions.in             |  2 ++
 src/control/control.c       | 24 ++++++++++++++++++++++++
 src/control/control_hw.c    | 20 ++++++++++++++++++++
 src/control/control_local.h |  2 ++
 6 files changed, 51 insertions(+)
diff mbox series

Patch

diff --git a/include/control.h b/include/control.h
index a2439d78057a..41892de20fd3 100644
--- a/include/control.h
+++ b/include/control.h
@@ -418,6 +418,8 @@  int snd_ctl_rawmidi_next_device(snd_ctl_t *ctl, int * device);
 int snd_ctl_rawmidi_info(snd_ctl_t *ctl, snd_rawmidi_info_t * info);
 int snd_ctl_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev);
 int snd_ctl_ump_next_device(snd_ctl_t *ctl, int *device);
+int snd_ctl_ump_endpoint_info(snd_ctl_t *ctl, snd_ump_endpoint_info_t *info);
+int snd_ctl_ump_block_info(snd_ctl_t *ctl, snd_ump_block_info_t *info);
 #endif
 int snd_ctl_set_power_state(snd_ctl_t *ctl, unsigned int state);
 int snd_ctl_get_power_state(snd_ctl_t *ctl, unsigned int *state);
diff --git a/include/local.h b/include/local.h
index 151e3fd4d39b..4206d68137d9 100644
--- a/include/local.h
+++ b/include/local.h
@@ -180,6 +180,7 @@ 
 #include "pcm.h"
 #include "pcm_plugin.h"
 #include "rawmidi.h"
+#include "ump.h"
 #include "timer.h"
 #include "hwdep.h"
 #include "control.h"
diff --git a/src/Versions.in b/src/Versions.in
index ee17cf289c0e..2acf3d1889df 100644
--- a/src/Versions.in
+++ b/src/Versions.in
@@ -154,4 +154,6 @@  ALSA_1.2.10 {
 
     @SYMBOL_PREFIX@snd_ump_*;
     @SYMBOL_PREFIX@snd_ctl_ump_next_device;
+    @SYMBOL_PREFIX@snd_ctl_ump_endpoint_info;
+    @SYMBOL_PREFIX@snd_ctl_ump_block_info;
 } ALSA_1.2.9;
diff --git a/src/control/control.c b/src/control/control.c
index 615a66906414..9b6bf893581b 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -1281,6 +1281,30 @@  int snd_ctl_ump_next_device(snd_ctl_t *ctl, int *device)
 	return -ENXIO;
 }
 
+/**
+ * \brief Get UMP Endpoint info about a UMP RawMidi device
+ * \param ctl CTL handle
+ * \param info UMP Endpoint info pointer
+ * \return 0 on success otherwise a negative error code
+ */
+int snd_ctl_ump_endpoint_info(snd_ctl_t *ctl, snd_ump_endpoint_info_t *info)
+{
+	assert(ctl && info);
+	return ctl->ops->ump_endpoint_info(ctl, info);
+}
+
+/**
+ * \brief Get UMP Block info about a UMP RawMidi device
+ * \param ctl CTL handle
+ * \param info UMP Block info pointer
+ * \return 0 on success otherwise a negative error code
+ */
+int snd_ctl_ump_block_info(snd_ctl_t *ctl, snd_ump_block_info_t *info)
+{
+	assert(ctl && info);
+	return ctl->ops->ump_block_info(ctl, info);
+}
+
 /**
  * \brief Set Power State to given SND_CTL_POWER_* value and do the power management
  * \param ctl CTL handle
diff --git a/src/control/control_hw.c b/src/control/control_hw.c
index ffb6f17325a7..a2f1bdc50cea 100644
--- a/src/control/control_hw.c
+++ b/src/control/control_hw.c
@@ -333,6 +333,24 @@  static int snd_ctl_hw_ump_next_device(snd_ctl_t *handle, int *device)
 	return 0;
 }
 
+static int snd_ctl_hw_ump_endpoint_info(snd_ctl_t *handle,
+					snd_ump_endpoint_info_t *info)
+{
+	snd_ctl_hw_t *hw = handle->private_data;
+	if (ioctl(hw->fd, SNDRV_CTL_IOCTL_UMP_ENDPOINT_INFO, info) < 0)
+		return -errno;
+	return 0;
+}
+
+static int snd_ctl_hw_ump_block_info(snd_ctl_t *handle,
+				     snd_ump_block_info_t *info)
+{
+	snd_ctl_hw_t *hw = handle->private_data;
+	if (ioctl(hw->fd, SNDRV_CTL_IOCTL_UMP_BLOCK_INFO, info) < 0)
+		return -errno;
+	return 0;
+}
+
 static int snd_ctl_hw_set_power_state(snd_ctl_t *handle, unsigned int state)
 {
 	snd_ctl_hw_t *hw = handle->private_data;
@@ -388,6 +406,8 @@  static const snd_ctl_ops_t snd_ctl_hw_ops = {
 	.rawmidi_info = snd_ctl_hw_rawmidi_info,
 	.rawmidi_prefer_subdevice = snd_ctl_hw_rawmidi_prefer_subdevice,
 	.ump_next_device = snd_ctl_hw_ump_next_device,
+	.ump_endpoint_info = snd_ctl_hw_ump_endpoint_info,
+	.ump_block_info = snd_ctl_hw_ump_block_info,
 	.set_power_state = snd_ctl_hw_set_power_state,
 	.get_power_state = snd_ctl_hw_get_power_state,
 	.read = snd_ctl_hw_read,
diff --git a/src/control/control_local.h b/src/control/control_local.h
index aa05bac84913..2afa62cceee3 100644
--- a/src/control/control_local.h
+++ b/src/control/control_local.h
@@ -48,6 +48,8 @@  typedef struct _snd_ctl_ops {
 	int (*rawmidi_info)(snd_ctl_t *handle, snd_rawmidi_info_t * info);
 	int (*rawmidi_prefer_subdevice)(snd_ctl_t *handle, int subdev);
 	int (*ump_next_device)(snd_ctl_t *handle, int *device);
+	int (*ump_endpoint_info)(snd_ctl_t *handle, snd_ump_endpoint_info_t *info);
+	int (*ump_block_info)(snd_ctl_t *handle, snd_ump_block_info_t *info);
 	int (*set_power_state)(snd_ctl_t *handle, unsigned int state);
 	int (*get_power_state)(snd_ctl_t *handle, unsigned int *state);
 	int (*read)(snd_ctl_t *handle, snd_ctl_event_t *event);