seq_virmidi.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef __SOUND_SEQ_VIRMIDI_H
  2. #define __SOUND_SEQ_VIRMIDI_H
  3. /*
  4. * Virtual Raw MIDI client on Sequencer
  5. * Copyright (c) 2000 by Takashi Iwai <tiwai@suse.de>,
  6. * Jaroslav Kysela <perex@perex.cz>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <sound/rawmidi.h>
  24. #include <sound/seq_midi_event.h>
  25. /*
  26. * device file instance:
  27. * This instance is created at each time the midi device file is
  28. * opened. Each instance has its own input buffer and MIDI parser
  29. * (buffer), and is associated with the device instance.
  30. */
  31. struct snd_virmidi {
  32. struct list_head list;
  33. int seq_mode;
  34. int client;
  35. int port;
  36. bool trigger;
  37. struct snd_midi_event *parser;
  38. struct snd_seq_event event;
  39. struct snd_virmidi_dev *rdev;
  40. struct snd_rawmidi_substream *substream;
  41. struct work_struct output_work;
  42. };
  43. #define SNDRV_VIRMIDI_SUBSCRIBE (1<<0)
  44. #define SNDRV_VIRMIDI_USE (1<<1)
  45. /*
  46. * device record:
  47. * Each virtual midi device has one device instance. It contains
  48. * common information and the linked-list of opened files,
  49. */
  50. struct snd_virmidi_dev {
  51. struct snd_card *card; /* associated card */
  52. struct snd_rawmidi *rmidi; /* rawmidi device */
  53. int seq_mode; /* SNDRV_VIRMIDI_XXX */
  54. int device; /* sequencer device */
  55. int client; /* created/attached client */
  56. int port; /* created/attached port */
  57. unsigned int flags; /* SNDRV_VIRMIDI_* */
  58. rwlock_t filelist_lock;
  59. struct rw_semaphore filelist_sem;
  60. struct list_head filelist;
  61. };
  62. /* sequencer mode:
  63. * ATTACH = input/output events from midi device are routed to the
  64. * attached sequencer port. sequencer port is not created
  65. * by virmidi itself.
  66. * the input to rawmidi must be processed by passing the
  67. * incoming events via snd_virmidi_receive()
  68. * DISPATCH = input/output events are routed to subscribers.
  69. * sequencer port is created in virmidi.
  70. */
  71. #define SNDRV_VIRMIDI_SEQ_NONE 0
  72. #define SNDRV_VIRMIDI_SEQ_ATTACH 1
  73. #define SNDRV_VIRMIDI_SEQ_DISPATCH 2
  74. int snd_virmidi_new(struct snd_card *card, int device, struct snd_rawmidi **rrmidi);
  75. #endif /* __SOUND_SEQ_VIRMIDI */