Skip to content

Commit

Permalink
seq: Add snd_seq_{get|set}_ump_is_midi1() API functions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
tiwai committed Aug 7, 2024
1 parent d969439 commit ddc4c66
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions include/sound/uapi/asequencer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/Versions.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
29 changes: 29 additions & 0 deletions src/seq/seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ddc4c66

Please sign in to comment.