Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ALSA: seq: Add UMP group filter

Add a new filter bitmap for UMP groups for reducing the unnecessary
read/write when the client is connected to UMP EP seq port.

The new group_filter field contains the bitmap for the groups, i.e.
when the bit is set, the corresponding group is filtered out and
the messages to that group won't be delivered.

The filter bitmap consists of each bit of 1-based UMP Group number.
The bit 0 is reserved for the future use.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230523075358.9672-37-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+18 -1
+2 -1
include/uapi/sound/asequencer.h
··· 362 362 int card; /* RO: card number[kernel] */ 363 363 int pid; /* RO: pid[user] */ 364 364 unsigned int midi_version; /* MIDI version */ 365 - char reserved[52]; /* for future use */ 365 + unsigned int group_filter; /* UMP group filter bitmap (for 1-based Group indices) */ 366 + char reserved[48]; /* for future use */ 366 367 }; 367 368 368 369 /* MIDI version numbers in client info */
+2
sound/core/seq/seq_clientmgr.c
··· 1229 1229 info->filter = cptr->filter; 1230 1230 info->event_lost = cptr->event_lost; 1231 1231 memcpy(info->event_filter, cptr->event_filter, 32); 1232 + info->group_filter = cptr->group_filter; 1232 1233 info->num_ports = cptr->num_ports; 1233 1234 1234 1235 if (cptr->type == USER_CLIENT) ··· 1291 1290 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3)) 1292 1291 client->midi_version = client_info->midi_version; 1293 1292 memcpy(client->event_filter, client_info->event_filter, 32); 1293 + client->group_filter = client_info->group_filter; 1294 1294 return 0; 1295 1295 } 1296 1296
+1
sound/core/seq/seq_clientmgr.h
··· 40 40 int number; /* client number */ 41 41 unsigned int filter; /* filter flags */ 42 42 DECLARE_BITMAP(event_filter, 256); 43 + unsigned short group_filter; 43 44 snd_use_lock_t use_lock; 44 45 int event_lost; 45 46 /* ports */
+13
sound/core/seq/seq_ump_convert.c
··· 527 527 atomic, hop); 528 528 } 529 529 530 + /* apply the UMP event filter; return true to skip the event */ 531 + static bool ump_event_filtered(struct snd_seq_client *dest, 532 + const struct snd_seq_ump_event *ev) 533 + { 534 + unsigned char group; 535 + 536 + group = ump_message_group(ev->ump[0]); 537 + /* check the bitmap for 1-based group number */ 538 + return dest->group_filter & (1U << (group + 1)); 539 + } 540 + 530 541 /* Convert from UMP packet and deliver */ 531 542 int snd_seq_deliver_from_ump(struct snd_seq_client *source, 532 543 struct snd_seq_client *dest, ··· 550 539 551 540 if (snd_seq_ev_is_variable(event)) 552 541 return 0; // skip, no variable event for UMP, so far 542 + if (ump_event_filtered(dest, ump_ev)) 543 + return 0; // skip if group filter is set and matching 553 544 type = ump_message_type(ump_ev->ump[0]); 554 545 555 546 if (snd_seq_client_is_ump(dest)) {