Skip to content

Commit

Permalink
ALSA: ump: Add legacy raw MIDI support
Browse files Browse the repository at this point in the history
This patch extends the UMP core code to support the legacy MIDI 1.0
rawmidi devices.  When the new kconfig CONFIG_SND_UMP_LEGACY_RAWMIDI
is set, the UMP core allows to attach an additional rawmidi device for
each UMP Endpoint.  The rawmidi device contains 16 substreams where
each substream corresponds to a UMP Group belonging to the EP.  The
device reads/writes the legacy MIDI 1.0 byte streams and translates
from/to UMP packets.

The legacy rawmidi devices are exclusive with the UMP rawmidi devices,
hence both of them can't be opened at the same time unless the UMP
rawmidi is opened in APPEND mode.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230523075358.9672-15-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed May 23, 2023
1 parent 6b41e64 commit 0b5288f
Show file tree
Hide file tree
Showing 7 changed files with 1,398 additions and 3 deletions.
30 changes: 30 additions & 0 deletions include/sound/ump.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
struct snd_ump_endpoint;
struct snd_ump_block;
struct snd_ump_ops;
struct ump_cvt_to_ump;

struct snd_ump_endpoint {
struct snd_rawmidi core; /* raw UMP access */
Expand All @@ -23,6 +24,24 @@ struct snd_ump_endpoint {
void (*private_free)(struct snd_ump_endpoint *ump);

struct list_head block_list; /* list of snd_ump_block objects */

/* intermediate buffer for UMP input */
u32 input_buf[4];
int input_buf_head;
int input_pending;

#if IS_ENABLED(CONFIG_SND_UMP_LEGACY_RAWMIDI)
struct mutex open_mutex;

spinlock_t legacy_locks[2];
struct snd_rawmidi *legacy_rmidi;
struct snd_rawmidi_substream *legacy_substreams[2][SNDRV_UMP_MAX_GROUPS];

/* for legacy output; need to open the actual substream unlike input */
int legacy_out_opens;
struct snd_rawmidi_file legacy_out_rfile;
struct ump_cvt_to_ump *out_cvts;
#endif
};

/* ops filled by UMP drivers */
Expand Down Expand Up @@ -54,6 +73,17 @@ int snd_ump_block_new(struct snd_ump_endpoint *ump, unsigned int blk,
int snd_ump_receive(struct snd_ump_endpoint *ump, const u32 *buffer, int count);
int snd_ump_transmit(struct snd_ump_endpoint *ump, u32 *buffer, int count);

#if IS_ENABLED(CONFIG_SND_UMP_LEGACY_RAWMIDI)
int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
char *id, int device);
#else
static inline int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
char *id, int device)
{
return 0;
}
#endif

/*
* Some definitions for UMP
*/
Expand Down
Loading

0 comments on commit 0b5288f

Please sign in to comment.