seq_instr.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef __SOUND_SEQ_INSTR_H
  2. #define __SOUND_SEQ_INSTR_H
  3. /*
  4. * Main kernel header file for the ALSA sequencer
  5. * Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
  6. *
  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 "seq_kernel.h"
  24. /* Instrument cluster */
  25. struct snd_seq_kcluster {
  26. snd_seq_instr_cluster_t cluster;
  27. char name[32];
  28. int priority;
  29. struct snd_seq_kcluster *next;
  30. };
  31. /* return pointer to private data */
  32. #define KINSTR_DATA(kinstr) (void *)(((char *)kinstr) + sizeof(struct snd_seq_kinstr))
  33. /* Instrument structure */
  34. struct snd_seq_kinstr {
  35. struct snd_seq_instr instr;
  36. char name[32];
  37. int type; /* instrument type */
  38. int use; /* use count */
  39. int busy; /* not useable */
  40. int add_len; /* additional length */
  41. struct snd_seq_kinstr_ops *ops; /* operations */
  42. struct snd_seq_kinstr *next;
  43. };
  44. #define SNDRV_SEQ_INSTR_HASH_SIZE 32
  45. /* Instrument flags */
  46. #define SNDRV_SEQ_INSTR_FLG_DIRECT (1<<0) /* accept only direct events */
  47. /* List of all instruments */
  48. struct snd_seq_kinstr_list {
  49. struct snd_seq_kinstr *hash[SNDRV_SEQ_INSTR_HASH_SIZE];
  50. int count; /* count of all instruments */
  51. struct snd_seq_kcluster *chash[SNDRV_SEQ_INSTR_HASH_SIZE];
  52. int ccount; /* count of all clusters */
  53. int owner; /* current owner of the instrument list */
  54. unsigned int flags;
  55. spinlock_t lock;
  56. spinlock_t ops_lock;
  57. struct mutex ops_mutex;
  58. unsigned long ops_flags;
  59. };
  60. #define SNDRV_SEQ_INSTR_NOTIFY_REMOVE 0
  61. #define SNDRV_SEQ_INSTR_NOTIFY_CHANGE 1
  62. struct snd_seq_kinstr_ops {
  63. void *private_data;
  64. long add_len; /* additional length */
  65. char *instr_type;
  66. int (*info)(void *private_data, char *info_data, long len);
  67. int (*put)(void *private_data, struct snd_seq_kinstr *kinstr,
  68. char __user *instr_data, long len, int atomic, int cmd);
  69. int (*get)(void *private_data, struct snd_seq_kinstr *kinstr,
  70. char __user *instr_data, long len, int atomic, int cmd);
  71. int (*get_size)(void *private_data, struct snd_seq_kinstr *kinstr, long *size);
  72. int (*remove)(void *private_data, struct snd_seq_kinstr *kinstr, int atomic);
  73. void (*notify)(void *private_data, struct snd_seq_kinstr *kinstr, int what);
  74. struct snd_seq_kinstr_ops *next;
  75. };
  76. /* instrument operations */
  77. struct snd_seq_kinstr_list *snd_seq_instr_list_new(void);
  78. void snd_seq_instr_list_free(struct snd_seq_kinstr_list **list);
  79. int snd_seq_instr_list_free_cond(struct snd_seq_kinstr_list *list,
  80. struct snd_seq_instr_header *ifree,
  81. int client,
  82. int atomic);
  83. struct snd_seq_kinstr *snd_seq_instr_find(struct snd_seq_kinstr_list *list,
  84. struct snd_seq_instr *instr,
  85. int exact,
  86. int follow_alias);
  87. void snd_seq_instr_free_use(struct snd_seq_kinstr_list *list,
  88. struct snd_seq_kinstr *instr);
  89. int snd_seq_instr_event(struct snd_seq_kinstr_ops *ops,
  90. struct snd_seq_kinstr_list *list,
  91. struct snd_seq_event *ev,
  92. int client,
  93. int atomic,
  94. int hop);
  95. #endif /* __SOUND_SEQ_INSTR_H */