blob: 796ce7772213aa2c154fa431f3ef5dcc8ad558c1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __SOUND_SEQ_VIRMIDI_H
2#define __SOUND_SEQ_VIRMIDI_H
3
4/*
5 * Virtual Raw MIDI client on Sequencer
6 * Copyright (c) 2000 by Takashi Iwai <tiwai@suse.de>,
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02007 * Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
David Howellsa1ce3922012-10-02 18:01:25 +010025#include <sound/rawmidi.h>
26#include <sound/seq_midi_event.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Linus Torvalds1da177e2005-04-16 15:20:36 -070028/*
29 * device file instance:
30 * This instance is created at each time the midi device file is
31 * opened. Each instance has its own input buffer and MIDI parser
32 * (buffer), and is associated with the device instance.
33 */
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010034struct snd_virmidi {
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 struct list_head list;
36 int seq_mode;
37 int client;
38 int port;
Takashi Iwai89b4ab22018-07-30 14:48:29 +020039 bool trigger;
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010040 struct snd_midi_event *parser;
41 struct snd_seq_event event;
42 struct snd_virmidi_dev *rdev;
43 struct snd_rawmidi_substream *substream;
Takashi Iwaif7debfe2018-07-29 23:03:05 +020044 struct work_struct output_work;
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010045};
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47#define SNDRV_VIRMIDI_SUBSCRIBE (1<<0)
48#define SNDRV_VIRMIDI_USE (1<<1)
49
50/*
51 * device record:
52 * Each virtual midi device has one device instance. It contains
53 * common information and the linked-list of opened files,
54 */
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010055struct snd_virmidi_dev {
56 struct snd_card *card; /* associated card */
57 struct snd_rawmidi *rmidi; /* rawmidi device */
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 int seq_mode; /* SNDRV_VIRMIDI_XXX */
59 int device; /* sequencer device */
60 int client; /* created/attached client */
61 int port; /* created/attached port */
62 unsigned int flags; /* SNDRV_VIRMIDI_* */
63 rwlock_t filelist_lock;
Takashi Iwai5803b022017-10-09 10:02:56 +020064 struct rw_semaphore filelist_sem;
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 struct list_head filelist;
66};
67
68/* sequencer mode:
69 * ATTACH = input/output events from midi device are routed to the
70 * attached sequencer port. sequencer port is not created
71 * by virmidi itself.
72 * the input to rawmidi must be processed by passing the
73 * incoming events via snd_virmidi_receive()
74 * DISPATCH = input/output events are routed to subscribers.
75 * sequencer port is created in virmidi.
76 */
77#define SNDRV_VIRMIDI_SEQ_NONE 0
78#define SNDRV_VIRMIDI_SEQ_ATTACH 1
79#define SNDRV_VIRMIDI_SEQ_DISPATCH 2
80
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010081int snd_virmidi_new(struct snd_card *card, int device, struct snd_rawmidi **rrmidi);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83#endif /* __SOUND_SEQ_VIRMIDI */