Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 #ifndef __SOUND_SEQ_VIRMIDI_H
0003 #define __SOUND_SEQ_VIRMIDI_H
0004 
0005 /*
0006  *  Virtual Raw MIDI client on Sequencer
0007  *  Copyright (c) 2000 by Takashi Iwai <tiwai@suse.de>,
0008  *                        Jaroslav Kysela <perex@perex.cz>
0009  */
0010 
0011 #include <sound/rawmidi.h>
0012 #include <sound/seq_midi_event.h>
0013 
0014 /*
0015  * device file instance:
0016  * This instance is created at each time the midi device file is
0017  * opened.  Each instance has its own input buffer and MIDI parser
0018  * (buffer), and is associated with the device instance.
0019  */
0020 struct snd_virmidi {
0021     struct list_head list;
0022     int seq_mode;
0023     int client;
0024     int port;
0025     bool trigger;
0026     struct snd_midi_event *parser;
0027     struct snd_seq_event event;
0028     struct snd_virmidi_dev *rdev;
0029     struct snd_rawmidi_substream *substream;
0030     struct work_struct output_work;
0031 };
0032 
0033 #define SNDRV_VIRMIDI_SUBSCRIBE     (1<<0)
0034 #define SNDRV_VIRMIDI_USE       (1<<1)
0035 
0036 /*
0037  * device record:
0038  * Each virtual midi device has one device instance.  It contains
0039  * common information and the linked-list of opened files, 
0040  */
0041 struct snd_virmidi_dev {
0042     struct snd_card *card;      /* associated card */
0043     struct snd_rawmidi *rmidi;      /* rawmidi device */
0044     int seq_mode;           /* SNDRV_VIRMIDI_XXX */
0045     int device;         /* sequencer device */
0046     int client;         /* created/attached client */
0047     int port;           /* created/attached port */
0048     unsigned int flags;     /* SNDRV_VIRMIDI_* */
0049     rwlock_t filelist_lock;
0050     struct rw_semaphore filelist_sem;
0051     struct list_head filelist;
0052 };
0053 
0054 /* sequencer mode:
0055  * ATTACH = input/output events from midi device are routed to the
0056  *          attached sequencer port.  sequencer port is not created
0057  *          by virmidi itself.
0058  *          the input to rawmidi must be processed by passing the
0059  *          incoming events via snd_virmidi_receive()
0060  * DISPATCH = input/output events are routed to subscribers.
0061  *            sequencer port is created in virmidi.
0062  */
0063 #define SNDRV_VIRMIDI_SEQ_NONE      0
0064 #define SNDRV_VIRMIDI_SEQ_ATTACH    1
0065 #define SNDRV_VIRMIDI_SEQ_DISPATCH  2
0066 
0067 int snd_virmidi_new(struct snd_card *card, int device, struct snd_rawmidi **rrmidi);
0068 
0069 #endif /* __SOUND_SEQ_VIRMIDI */