Skip to content

Commit 0b5288f

Browse files
committed
ALSA: ump: Add legacy raw MIDI support
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 6b41e64 commit 0b5288f

File tree

7 files changed

+1398
-3
lines changed

7 files changed

+1398
-3
lines changed

include/sound/ump.h

+30
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
struct snd_ump_endpoint;
1111
struct snd_ump_block;
1212
struct snd_ump_ops;
13+
struct ump_cvt_to_ump;
1314

1415
struct snd_ump_endpoint {
1516
struct snd_rawmidi core; /* raw UMP access */
@@ -23,6 +24,24 @@ struct snd_ump_endpoint {
2324
void (*private_free)(struct snd_ump_endpoint *ump);
2425

2526
struct list_head block_list; /* list of snd_ump_block objects */
27+
28+
/* intermediate buffer for UMP input */
29+
u32 input_buf[4];
30+
int input_buf_head;
31+
int input_pending;
32+
33+
#if IS_ENABLED(CONFIG_SND_UMP_LEGACY_RAWMIDI)
34+
struct mutex open_mutex;
35+
36+
spinlock_t legacy_locks[2];
37+
struct snd_rawmidi *legacy_rmidi;
38+
struct snd_rawmidi_substream *legacy_substreams[2][SNDRV_UMP_MAX_GROUPS];
39+
40+
/* for legacy output; need to open the actual substream unlike input */
41+
int legacy_out_opens;
42+
struct snd_rawmidi_file legacy_out_rfile;
43+
struct ump_cvt_to_ump *out_cvts;
44+
#endif
2645
};
2746

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

76+
#if IS_ENABLED(CONFIG_SND_UMP_LEGACY_RAWMIDI)
77+
int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
78+
char *id, int device);
79+
#else
80+
static inline int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
81+
char *id, int device)
82+
{
83+
return 0;
84+
}
85+
#endif
86+
5787
/*
5888
* Some definitions for UMP
5989
*/

0 commit comments

Comments
 (0)