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