Skip to content

Commit 3bfd7c0

Browse files
committed
ALSA: seq: ump: Skip useless ports for static blocks
When the UMP Endpoint is configured with static blocks, the block configuration will never change, hence the unused ports will be unchanged as well. Creating sequencer ports for those unused ports is simply useless, and it might be rather confusing for users. The idea behind the inactive ports was for allowing connections from/to ports that can become usable later, but this will never happen for inactive groups in static blocks. Let's change the sequencer UMP binding to skip those unused ports when the UMP EP is with static blocks. Fixes: 81fd444 ("ALSA: seq: Bind UMP device") Cc: <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 88e98af commit 3bfd7c0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sound/core/seq/seq_ump_client.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct seq_ump_group {
2828
int group; /* group index (0-based) */
2929
unsigned int dir_bits; /* directions */
3030
bool active; /* activeness */
31+
bool valid; /* valid group (referred by blocks) */
3132
char name[64]; /* seq port name */
3233
};
3334

@@ -210,13 +211,23 @@ static void fill_port_info(struct snd_seq_port_info *port,
210211
sprintf(port->name, "Group %d", group->group + 1);
211212
}
212213

214+
/* skip non-existing group for static blocks */
215+
static bool skip_group(struct seq_ump_client *client, struct seq_ump_group *group)
216+
{
217+
return !group->valid &&
218+
(client->ump->info.flags & SNDRV_UMP_EP_INFO_STATIC_BLOCKS);
219+
}
220+
213221
/* create a new sequencer port per UMP group */
214222
static int seq_ump_group_init(struct seq_ump_client *client, int group_index)
215223
{
216224
struct seq_ump_group *group = &client->groups[group_index];
217225
struct snd_seq_port_info *port __free(kfree) = NULL;
218226
struct snd_seq_port_callback pcallbacks;
219227

228+
if (skip_group(client, group))
229+
return 0;
230+
220231
port = kzalloc(sizeof(*port), GFP_KERNEL);
221232
if (!port)
222233
return -ENOMEM;
@@ -250,6 +261,9 @@ static void update_port_infos(struct seq_ump_client *client)
250261
return;
251262

252263
for (i = 0; i < SNDRV_UMP_MAX_GROUPS; i++) {
264+
if (skip_group(client, &client->groups[i]))
265+
continue;
266+
253267
old->addr.client = client->seq_client;
254268
old->addr.port = i;
255269
err = snd_seq_kernel_client_ctl(client->seq_client,
@@ -284,13 +298,15 @@ static void update_group_attrs(struct seq_ump_client *client)
284298
group->dir_bits = 0;
285299
group->active = 0;
286300
group->group = i;
301+
group->valid = false;
287302
}
288303

289304
list_for_each_entry(fb, &client->ump->block_list, list) {
290305
if (fb->info.first_group + fb->info.num_groups > SNDRV_UMP_MAX_GROUPS)
291306
break;
292307
group = &client->groups[fb->info.first_group];
293308
for (i = 0; i < fb->info.num_groups; i++, group++) {
309+
group->valid = true;
294310
if (fb->info.active)
295311
group->active = 1;
296312
switch (fb->info.direction) {

0 commit comments

Comments
 (0)