xref: /linux/include/sound/seq_virmidi.h (revision 59e6295fac26b8e85c1ea859cdd89fa1e47519d7)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef __SOUND_SEQ_VIRMIDI_H
3 #define __SOUND_SEQ_VIRMIDI_H
4 
5 /*
6  *  Virtual Raw MIDI client on Sequencer
7  *  Copyright (c) 2000 by Takashi Iwai <tiwai@suse.de>,
8  *                        Jaroslav Kysela <perex@perex.cz>
9  */
10 
11 #include <sound/rawmidi.h>
12 #include <sound/seq_midi_event.h>
13 
14 /*
15  * device file instance:
16  * This instance is created at each time the midi device file is
17  * opened.  Each instance has its own input buffer and MIDI parser
18  * (buffer), and is associated with the device instance.
19  */
20 struct snd_virmidi {
21 	struct list_head list;
22 	int seq_mode;
23 	int client;
24 	int port;
25 	bool trigger;
26 	struct snd_midi_event *parser;
27 	struct snd_seq_event event;
28 	struct snd_virmidi_dev *rdev;
29 	struct snd_rawmidi_substream *substream;
30 	struct work_struct output_work;
31 };
32 
33 #define SNDRV_VIRMIDI_SUBSCRIBE		(1<<0)
34 #define SNDRV_VIRMIDI_USE		(1<<1)
35 
36 /*
37  * device record:
38  * Each virtual midi device has one device instance.  It contains
39  * common information and the linked-list of opened files,
40  */
41 struct snd_virmidi_dev {
42 	struct snd_card *card;		/* associated card */
43 	struct snd_rawmidi *rmidi;		/* rawmidi device */
44 	int seq_mode;			/* SNDRV_VIRMIDI_XXX */
45 	int device;			/* sequencer device */
46 	int client;			/* created/attached client */
47 	int port;			/* created/attached port */
48 	unsigned int flags;		/* SNDRV_VIRMIDI_* */
49 	struct rw_semaphore filelist_sem;
50 	struct list_head filelist;
51 };
52 
53 /* sequencer mode:
54  * ATTACH = input/output events from midi device are routed to the
55  *          attached sequencer port.  sequencer port is not created
56  *          by virmidi itself.
57  *          the input to rawmidi must be processed by passing the
58  *          incoming events via snd_virmidi_receive()
59  * DISPATCH = input/output events are routed to subscribers.
60  *            sequencer port is created in virmidi.
61  */
62 #define SNDRV_VIRMIDI_SEQ_NONE		0
63 #define SNDRV_VIRMIDI_SEQ_ATTACH	1
64 #define SNDRV_VIRMIDI_SEQ_DISPATCH	2
65 
66 int snd_virmidi_new(struct snd_card *card, int device, struct snd_rawmidi **rrmidi);
67 
68 #endif /* __SOUND_SEQ_VIRMIDI */
69