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