seq_virmidi.h 2.1 KB

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