Skip to content

Commit 81fd444

Browse files
committed
ALSA: seq: Bind UMP device
This patch introduces a new ALSA sequencer client for the kernel UMP object, snd-seq-ump-client. It's a UMP version of snd-seq-midi driver, while this driver creates a sequencer client per UMP endpoint which contains (fixed) 16 ports. The UMP rawmidi device is opened in APPEND mode for output, so that multiple sequencer clients can share the same UMP endpoint, as well as the legacy UMP rawmidi devices that are opened in APPEND mode, too. For input, on the other hand, the incoming data is processed on the fly in the dedicated hook, hence it doesn't open a rawmidi device. The UMP packet group is updated upon delivery depending on the target sequencer port (which corresponds to the actual UMP group). Each sequencer port sets a new port type bit, SNDRV_SEQ_PORT_TYPE_MIDI_UMP, in addition to the other standard types for MIDI. Reviewed-by: Jaroslav Kysela <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 329ffe1 commit 81fd444

File tree

7 files changed

+439
-2
lines changed

7 files changed

+439
-2
lines changed

include/sound/seq_device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ void snd_seq_driver_unregister(struct snd_seq_driver *drv);
7878
*/
7979
#define SNDRV_SEQ_DEV_ID_MIDISYNTH "seq-midi"
8080
#define SNDRV_SEQ_DEV_ID_OPL3 "opl3-synth"
81+
#define SNDRV_SEQ_DEV_ID_UMP "seq-ump-client"
8182

8283
#endif /* __SOUND_SEQ_DEVICE_H */

include/sound/ump.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct snd_ump_endpoint;
1111
struct snd_ump_block;
1212
struct snd_ump_ops;
1313
struct ump_cvt_to_ump;
14+
struct snd_seq_ump_ops;
1415

1516
struct snd_ump_endpoint {
1617
struct snd_rawmidi core; /* raw UMP access */
@@ -30,9 +31,9 @@ struct snd_ump_endpoint {
3031
int input_buf_head;
3132
int input_pending;
3233

33-
#if IS_ENABLED(CONFIG_SND_UMP_LEGACY_RAWMIDI)
3434
struct mutex open_mutex;
3535

36+
#if IS_ENABLED(CONFIG_SND_UMP_LEGACY_RAWMIDI)
3637
spinlock_t legacy_locks[2];
3738
struct snd_rawmidi *legacy_rmidi;
3839
struct snd_rawmidi_substream *legacy_substreams[2][SNDRV_UMP_MAX_GROUPS];
@@ -42,6 +43,12 @@ struct snd_ump_endpoint {
4243
struct snd_rawmidi_file legacy_out_rfile;
4344
struct ump_cvt_to_ump *out_cvts;
4445
#endif
46+
47+
#if IS_ENABLED(CONFIG_SND_SEQUENCER)
48+
struct snd_seq_device *seq_dev;
49+
const struct snd_seq_ump_ops *seq_ops;
50+
void *seq_client;
51+
#endif
4552
};
4653

4754
/* ops filled by UMP drivers */
@@ -52,6 +59,12 @@ struct snd_ump_ops {
5259
void (*drain)(struct snd_ump_endpoint *ump, int dir);
5360
};
5461

62+
/* ops filled by sequencer binding */
63+
struct snd_seq_ump_ops {
64+
void (*input_receive)(struct snd_ump_endpoint *ump,
65+
const u32 *data, int words);
66+
};
67+
5568
struct snd_ump_block {
5669
struct snd_ump_block_info info;
5770
struct snd_ump_endpoint *ump;

include/uapi/sound/asequencer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ struct snd_seq_remove_events {
439439
#define SNDRV_SEQ_PORT_TYPE_MIDI_XG (1<<4) /* XG compatible device */
440440
#define SNDRV_SEQ_PORT_TYPE_MIDI_MT32 (1<<5) /* MT-32 compatible device */
441441
#define SNDRV_SEQ_PORT_TYPE_MIDI_GM2 (1<<6) /* General MIDI 2 compatible device */
442+
#define SNDRV_SEQ_PORT_TYPE_MIDI_UMP (1<<7) /* UMP */
442443

443444
/* other standards...*/
444445
#define SNDRV_SEQ_PORT_TYPE_SYNTH (1<<10) /* Synth device (no MIDI compatible - direct wavetable) */

sound/core/seq/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,16 @@ config SND_SEQ_VIRMIDI
6262

6363
config SND_SEQ_UMP
6464
bool "Support for UMP events"
65+
default y if SND_SEQ_UMP_CLIENT
6566
help
6667
Say Y here to enable the support for handling UMP (Universal MIDI
6768
Packet) events via ALSA sequencer infrastructure, which is an
6869
essential feature for enabling MIDI 2.0 support.
6970
It includes the automatic conversion of ALSA sequencer events
7071
among legacy and UMP clients.
7172

73+
config SND_SEQ_UMP_CLIENT
74+
tristate
75+
def_tristate SND_UMP
76+
7277
endif # SND_SEQUENCER

sound/core/seq/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ snd-seq-midi-emul-objs := seq_midi_emul.o
1414
snd-seq-midi-event-objs := seq_midi_event.o
1515
snd-seq-dummy-objs := seq_dummy.o
1616
snd-seq-virmidi-objs := seq_virmidi.o
17+
snd-seq-ump-client-objs := seq_ump_client.o
1718

1819
obj-$(CONFIG_SND_SEQUENCER) += snd-seq.o
1920
obj-$(CONFIG_SND_SEQUENCER_OSS) += oss/
2021

2122
obj-$(CONFIG_SND_SEQ_DUMMY) += snd-seq-dummy.o
2223
obj-$(CONFIG_SND_SEQ_MIDI) += snd-seq-midi.o
24+
obj-$(CONFIG_SND_SEQ_UMP_CLIENT) += snd-seq-ump-client.o
2325
obj-$(CONFIG_SND_SEQ_MIDI_EMUL) += snd-seq-midi-emul.o
2426
obj-$(CONFIG_SND_SEQ_MIDI_EVENT) += snd-seq-midi-event.o
2527
obj-$(CONFIG_SND_SEQ_VIRMIDI) += snd-seq-virmidi.o

0 commit comments

Comments
 (0)