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: 81fd444aa3
("ALSA: seq: Bind UMP device")
Cc: <stable@vger.kernel.org>
Link: https://patch.msgid.link/20240717083322.25892-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
88e98af9f4
commit
3bfd7c0ba1
@ -28,6 +28,7 @@ struct seq_ump_group {
|
|||||||
int group; /* group index (0-based) */
|
int group; /* group index (0-based) */
|
||||||
unsigned int dir_bits; /* directions */
|
unsigned int dir_bits; /* directions */
|
||||||
bool active; /* activeness */
|
bool active; /* activeness */
|
||||||
|
bool valid; /* valid group (referred by blocks) */
|
||||||
char name[64]; /* seq port name */
|
char name[64]; /* seq port name */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -210,6 +211,13 @@ static void fill_port_info(struct snd_seq_port_info *port,
|
|||||||
sprintf(port->name, "Group %d", group->group + 1);
|
sprintf(port->name, "Group %d", group->group + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* skip non-existing group for static blocks */
|
||||||
|
static bool skip_group(struct seq_ump_client *client, struct seq_ump_group *group)
|
||||||
|
{
|
||||||
|
return !group->valid &&
|
||||||
|
(client->ump->info.flags & SNDRV_UMP_EP_INFO_STATIC_BLOCKS);
|
||||||
|
}
|
||||||
|
|
||||||
/* create a new sequencer port per UMP group */
|
/* create a new sequencer port per UMP group */
|
||||||
static int seq_ump_group_init(struct seq_ump_client *client, int group_index)
|
static int seq_ump_group_init(struct seq_ump_client *client, int group_index)
|
||||||
{
|
{
|
||||||
@ -217,6 +225,9 @@ static int seq_ump_group_init(struct seq_ump_client *client, int group_index)
|
|||||||
struct snd_seq_port_info *port __free(kfree) = NULL;
|
struct snd_seq_port_info *port __free(kfree) = NULL;
|
||||||
struct snd_seq_port_callback pcallbacks;
|
struct snd_seq_port_callback pcallbacks;
|
||||||
|
|
||||||
|
if (skip_group(client, group))
|
||||||
|
return 0;
|
||||||
|
|
||||||
port = kzalloc(sizeof(*port), GFP_KERNEL);
|
port = kzalloc(sizeof(*port), GFP_KERNEL);
|
||||||
if (!port)
|
if (!port)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -250,6 +261,9 @@ static void update_port_infos(struct seq_ump_client *client)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < SNDRV_UMP_MAX_GROUPS; i++) {
|
for (i = 0; i < SNDRV_UMP_MAX_GROUPS; i++) {
|
||||||
|
if (skip_group(client, &client->groups[i]))
|
||||||
|
continue;
|
||||||
|
|
||||||
old->addr.client = client->seq_client;
|
old->addr.client = client->seq_client;
|
||||||
old->addr.port = i;
|
old->addr.port = i;
|
||||||
err = snd_seq_kernel_client_ctl(client->seq_client,
|
err = snd_seq_kernel_client_ctl(client->seq_client,
|
||||||
@ -284,6 +298,7 @@ static void update_group_attrs(struct seq_ump_client *client)
|
|||||||
group->dir_bits = 0;
|
group->dir_bits = 0;
|
||||||
group->active = 0;
|
group->active = 0;
|
||||||
group->group = i;
|
group->group = i;
|
||||||
|
group->valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
list_for_each_entry(fb, &client->ump->block_list, list) {
|
list_for_each_entry(fb, &client->ump->block_list, list) {
|
||||||
@ -291,6 +306,7 @@ static void update_group_attrs(struct seq_ump_client *client)
|
|||||||
break;
|
break;
|
||||||
group = &client->groups[fb->info.first_group];
|
group = &client->groups[fb->info.first_group];
|
||||||
for (i = 0; i < fb->info.num_groups; i++, group++) {
|
for (i = 0; i < fb->info.num_groups; i++, group++) {
|
||||||
|
group->valid = true;
|
||||||
if (fb->info.active)
|
if (fb->info.active)
|
||||||
group->active = 1;
|
group->active = 1;
|
||||||
switch (fb->info.direction) {
|
switch (fb->info.direction) {
|
||||||
|
Loading…
Reference in New Issue
Block a user