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