Skip to content

Commit

Permalink
ALSA: ump: Add info flag bit for static blocks
Browse files Browse the repository at this point in the history
UMP v1.1 spec allows to inform whether the function blocks are static
and not dynamically updated.  Add a new flag bit to
snd_ump_endpoint_info to reflect that attribute, too.

The flag is set when a USB MIDI device is still in the old MIDI 2.0
without UMP 1.1 support.  Then the driver falls back to GTBs, and they
are supposed to be static-only.

Link: https://lore.kernel.org/r/20230612081054.17200-10-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Jun 12, 2023
1 parent 6a8b480 commit 01dfa8e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/uapi/sound/asound.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,9 @@ struct snd_rawmidi_status {
};
#endif

/* UMP EP info flags */
#define SNDRV_UMP_EP_INFO_STATIC_BLOCKS 0x01

/* UMP EP Protocol / JRTS capability bits */
#define SNDRV_UMP_EP_INFO_PROTO_MIDI_MASK 0x0300
#define SNDRV_UMP_EP_INFO_PROTO_MIDI1 0x0100 /* MIDI 1.0 */
Expand Down
11 changes: 11 additions & 0 deletions sound/core/ump.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ static void snd_ump_proc_read(struct snd_info_entry *entry,
ump->info.sw_revision[2],
ump->info.sw_revision[3]);
}
snd_iprintf(buffer, "Static Blocks: %s\n",
(ump->info.flags & SNDRV_UMP_EP_INFO_STATIC_BLOCKS) ? "Yes" : "No");
snd_iprintf(buffer, "Num Blocks: %d\n\n", ump->info.num_blocks);

list_for_each_entry(fb, &ump->block_list, list) {
Expand Down Expand Up @@ -608,6 +610,9 @@ static int ump_handle_ep_info_msg(struct snd_ump_endpoint *ump,
ump->info.num_blocks = 1;
}

if (buf->ep_info.static_function_block)
ump->info.flags |= SNDRV_UMP_EP_INFO_STATIC_BLOCKS;

ump->info.protocol_caps = (buf->ep_info.protocol << 8) |
buf->ep_info.jrts;

Expand Down Expand Up @@ -708,6 +713,12 @@ static bool is_fb_info_updated(struct snd_ump_endpoint *ump,
{
char tmpbuf[offsetof(struct snd_ump_block_info, name)];

if (ump->info.flags & SNDRV_UMP_EP_INFO_STATIC_BLOCKS) {
ump_info(ump, "Skipping static FB info update (blk#%d)\n",
fb->info.block_id);
return 0;
}

memcpy(tmpbuf, &fb->info, sizeof(tmpbuf));
fill_fb_info(ump, (struct snd_ump_block_info *)tmpbuf, buf);
return memcmp(&fb->info, tmpbuf, sizeof(tmpbuf)) != 0;
Expand Down
2 changes: 2 additions & 0 deletions sound/usb/midi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,8 @@ static int create_blocks_from_gtb(struct snd_usb_midi2_interface *umidi)
/* Blocks have been already created? */
if (rmidi->ump_parsed || rmidi->ump->info.num_blocks)
continue;
/* GTB is static-only */
rmidi->ump->info.flags |= SNDRV_UMP_EP_INFO_STATIC_BLOCKS;
/* loop over GTBs */
for (dir = 0; dir < 2; dir++) {
if (!rmidi->eps[dir])
Expand Down

0 comments on commit 01dfa8e

Please sign in to comment.