Skip to content

Commit

Permalink
control: Add UMP Endpoint and Block info query support
Browse files Browse the repository at this point in the history
Add functions to query the UMP Endpoint and Block info via control
interface.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
tiwai committed Jun 6, 2023
1 parent 8bc10c8 commit 81b0cf4
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions include/local.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/Versions.in
Original file line number Diff line number Diff line change
Expand Up @@ -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;
24 changes: 24 additions & 0 deletions src/control/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions src/control/control_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/control/control_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 81b0cf4

Please sign in to comment.