Skip to content

Commit 5437ac9

Browse files
committed
ALSA: seq: ump: Handle groupless messages
The UMP Utility and Stream messages are "groupless", i.e. an incoming groupless packet should be sent only to the UMP EP port, and the event with the groupless message is sent to UMP EP as is without the group translation per port. Also, the former reserved bit 0 for the client group filter is now used for groupless events. When the bit 0 is set, the groupless events are filtered out and skipped. Link: https://lore.kernel.org/r/20230612081054.17200-6-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 960a114 commit 5437ac9

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

include/sound/ump.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,7 @@ static inline u32 ump_stream_compose(unsigned char status, unsigned short form)
255255
((u32)status << 16);
256256
}
257257

258+
#define ump_is_groupless_msg(type) \
259+
((type) == UMP_MSG_TYPE_UTILITY || (type) == UMP_MSG_TYPE_STREAM)
260+
258261
#endif /* __SOUND_UMP_H */

include/uapi/sound/asequencer.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,10 @@ struct snd_seq_client_info {
362362
int card; /* RO: card number[kernel] */
363363
int pid; /* RO: pid[user] */
364364
unsigned int midi_version; /* MIDI version */
365-
unsigned int group_filter; /* UMP group filter bitmap (for 1-based Group indices) */
365+
unsigned int group_filter; /* UMP group filter bitmap
366+
* (bit 0 = groupless messages,
367+
* bit 1-16 = messages for groups 1-16)
368+
*/
366369
char reserved[48]; /* for future use */
367370
};
368371

sound/core/seq/seq_ump_client.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ static void seq_ump_input_receive(struct snd_ump_endpoint *ump,
7373
if (!client->opened[STR_IN])
7474
return;
7575

76-
ev.source.port = ump_group_to_seq_port(ump_message_group(*val));
76+
if (ump_is_groupless_msg(ump_message_type(*val)))
77+
ev.source.port = 0; /* UMP EP port */
78+
else
79+
ev.source.port = ump_group_to_seq_port(ump_message_group(*val));
7780
ev.dest.client = SNDRV_SEQ_ADDRESS_SUBSCRIBERS;
7881
ev.flags = SNDRV_SEQ_EVENT_UMP;
7982
memcpy(ev.ump, val, words << 2);

sound/core/seq/seq_ump_convert.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,8 @@ static bool ump_event_filtered(struct snd_seq_client *dest,
534534
unsigned char group;
535535

536536
group = ump_message_group(ev->ump[0]);
537+
if (ump_is_groupless_msg(ump_message_type(ev->ump[0])))
538+
return dest->group_filter & (1U << 0);
537539
/* check the bitmap for 1-based group number */
538540
return dest->group_filter & (1U << (group + 1));
539541
}
@@ -565,6 +567,7 @@ int snd_seq_deliver_from_ump(struct snd_seq_client *source,
565567
event, atomic, hop);
566568
/* non-EP port and different group is set? */
567569
if (dest_port->ump_group &&
570+
!ump_is_groupless_msg(type) &&
568571
ump_message_group(*ump_ev->ump) + 1 != dest_port->ump_group)
569572
return deliver_with_group_convert(dest, dest_port,
570573
ump_ev, atomic, hop);

0 commit comments

Comments
 (0)