1*1a59d1b8SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 21da177e4SLinus Torvalds #ifndef __SOUND_SEQ_VIRMIDI_H 31da177e4SLinus Torvalds #define __SOUND_SEQ_VIRMIDI_H 41da177e4SLinus Torvalds 51da177e4SLinus Torvalds /* 61da177e4SLinus Torvalds * Virtual Raw MIDI client on Sequencer 71da177e4SLinus Torvalds * Copyright (c) 2000 by Takashi Iwai <tiwai@suse.de>, 8c1017a4cSJaroslav Kysela * Jaroslav Kysela <perex@perex.cz> 91da177e4SLinus Torvalds */ 101da177e4SLinus Torvalds 11a1ce3928SDavid Howells #include <sound/rawmidi.h> 12a1ce3928SDavid Howells #include <sound/seq_midi_event.h> 131da177e4SLinus Torvalds 141da177e4SLinus Torvalds /* 151da177e4SLinus Torvalds * device file instance: 161da177e4SLinus Torvalds * This instance is created at each time the midi device file is 171da177e4SLinus Torvalds * opened. Each instance has its own input buffer and MIDI parser 181da177e4SLinus Torvalds * (buffer), and is associated with the device instance. 191da177e4SLinus Torvalds */ 20c7e0b5bfSTakashi Iwai struct snd_virmidi { 211da177e4SLinus Torvalds struct list_head list; 221da177e4SLinus Torvalds int seq_mode; 231da177e4SLinus Torvalds int client; 241da177e4SLinus Torvalds int port; 2589b4ab21STakashi Iwai bool trigger; 26c7e0b5bfSTakashi Iwai struct snd_midi_event *parser; 27c7e0b5bfSTakashi Iwai struct snd_seq_event event; 28c7e0b5bfSTakashi Iwai struct snd_virmidi_dev *rdev; 29c7e0b5bfSTakashi Iwai struct snd_rawmidi_substream *substream; 30f7debfe5STakashi Iwai struct work_struct output_work; 31c7e0b5bfSTakashi Iwai }; 321da177e4SLinus Torvalds 331da177e4SLinus Torvalds #define SNDRV_VIRMIDI_SUBSCRIBE (1<<0) 341da177e4SLinus Torvalds #define SNDRV_VIRMIDI_USE (1<<1) 351da177e4SLinus Torvalds 361da177e4SLinus Torvalds /* 371da177e4SLinus Torvalds * device record: 381da177e4SLinus Torvalds * Each virtual midi device has one device instance. It contains 391da177e4SLinus Torvalds * common information and the linked-list of opened files, 401da177e4SLinus Torvalds */ 41c7e0b5bfSTakashi Iwai struct snd_virmidi_dev { 42c7e0b5bfSTakashi Iwai struct snd_card *card; /* associated card */ 43c7e0b5bfSTakashi Iwai struct snd_rawmidi *rmidi; /* rawmidi device */ 441da177e4SLinus Torvalds int seq_mode; /* SNDRV_VIRMIDI_XXX */ 451da177e4SLinus Torvalds int device; /* sequencer device */ 461da177e4SLinus Torvalds int client; /* created/attached client */ 471da177e4SLinus Torvalds int port; /* created/attached port */ 481da177e4SLinus Torvalds unsigned int flags; /* SNDRV_VIRMIDI_* */ 491da177e4SLinus Torvalds rwlock_t filelist_lock; 505803b023STakashi Iwai struct rw_semaphore filelist_sem; 511da177e4SLinus Torvalds struct list_head filelist; 521da177e4SLinus Torvalds }; 531da177e4SLinus Torvalds 541da177e4SLinus Torvalds /* sequencer mode: 551da177e4SLinus Torvalds * ATTACH = input/output events from midi device are routed to the 561da177e4SLinus Torvalds * attached sequencer port. sequencer port is not created 571da177e4SLinus Torvalds * by virmidi itself. 581da177e4SLinus Torvalds * the input to rawmidi must be processed by passing the 591da177e4SLinus Torvalds * incoming events via snd_virmidi_receive() 601da177e4SLinus Torvalds * DISPATCH = input/output events are routed to subscribers. 611da177e4SLinus Torvalds * sequencer port is created in virmidi. 621da177e4SLinus Torvalds */ 631da177e4SLinus Torvalds #define SNDRV_VIRMIDI_SEQ_NONE 0 641da177e4SLinus Torvalds #define SNDRV_VIRMIDI_SEQ_ATTACH 1 651da177e4SLinus Torvalds #define SNDRV_VIRMIDI_SEQ_DISPATCH 2 661da177e4SLinus Torvalds 67c7e0b5bfSTakashi Iwai int snd_virmidi_new(struct snd_card *card, int device, struct snd_rawmidi **rrmidi); 681da177e4SLinus Torvalds 691da177e4SLinus Torvalds #endif /* __SOUND_SEQ_VIRMIDI */ 70