info.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #ifndef __SOUND_INFO_H
  2. #define __SOUND_INFO_H
  3. /*
  4. * Header file for info interface
  5. * Copyright (c) by Jaroslav Kysela <perex@perex.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 <linux/poll.h>
  24. /* buffer for information */
  25. struct snd_info_buffer {
  26. char *buffer; /* pointer to begin of buffer */
  27. unsigned int curr; /* current position in buffer */
  28. unsigned int size; /* current size */
  29. unsigned int len; /* total length of buffer */
  30. int stop; /* stop flag */
  31. int error; /* error code */
  32. };
  33. #define SNDRV_INFO_CONTENT_TEXT 0
  34. #define SNDRV_INFO_CONTENT_DATA 1
  35. struct snd_info_entry;
  36. struct snd_info_entry_text {
  37. void (*read)(struct snd_info_entry *entry,
  38. struct snd_info_buffer *buffer);
  39. void (*write)(struct snd_info_entry *entry,
  40. struct snd_info_buffer *buffer);
  41. };
  42. struct snd_info_entry_ops {
  43. int (*open)(struct snd_info_entry *entry,
  44. unsigned short mode, void **file_private_data);
  45. int (*release)(struct snd_info_entry *entry,
  46. unsigned short mode, void *file_private_data);
  47. ssize_t (*read)(struct snd_info_entry *entry, void *file_private_data,
  48. struct file *file, char __user *buf,
  49. size_t count, loff_t pos);
  50. ssize_t (*write)(struct snd_info_entry *entry, void *file_private_data,
  51. struct file *file, const char __user *buf,
  52. size_t count, loff_t pos);
  53. loff_t (*llseek)(struct snd_info_entry *entry,
  54. void *file_private_data, struct file *file,
  55. loff_t offset, int orig);
  56. unsigned int (*poll)(struct snd_info_entry *entry,
  57. void *file_private_data, struct file *file,
  58. poll_table *wait);
  59. int (*ioctl)(struct snd_info_entry *entry, void *file_private_data,
  60. struct file *file, unsigned int cmd, unsigned long arg);
  61. int (*mmap)(struct snd_info_entry *entry, void *file_private_data,
  62. struct inode *inode, struct file *file,
  63. struct vm_area_struct *vma);
  64. };
  65. struct snd_info_entry {
  66. const char *name;
  67. umode_t mode;
  68. long size;
  69. unsigned short content;
  70. union {
  71. struct snd_info_entry_text text;
  72. struct snd_info_entry_ops *ops;
  73. } c;
  74. struct snd_info_entry *parent;
  75. struct snd_card *card;
  76. struct module *module;
  77. void *private_data;
  78. void (*private_free)(struct snd_info_entry *entry);
  79. struct proc_dir_entry *p;
  80. struct mutex access;
  81. struct list_head children;
  82. struct list_head list;
  83. };
  84. #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
  85. int snd_info_minor_register(void);
  86. int snd_info_minor_unregister(void);
  87. #else
  88. #define snd_info_minor_register() /* NOP */
  89. #define snd_info_minor_unregister() /* NOP */
  90. #endif
  91. #ifdef CONFIG_PROC_FS
  92. extern struct snd_info_entry *snd_seq_root;
  93. #ifdef CONFIG_SND_OSSEMUL
  94. extern struct snd_info_entry *snd_oss_root;
  95. void snd_card_info_read_oss(struct snd_info_buffer *buffer);
  96. #else
  97. #define snd_oss_root NULL
  98. static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
  99. #endif
  100. __printf(2, 3)
  101. int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...);
  102. int snd_info_init(void);
  103. int snd_info_done(void);
  104. int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len);
  105. const char *snd_info_get_str(char *dest, const char *src, int len);
  106. struct snd_info_entry *snd_info_create_module_entry(struct module *module,
  107. const char *name,
  108. struct snd_info_entry *parent);
  109. struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card,
  110. const char *name,
  111. struct snd_info_entry *parent);
  112. void snd_info_free_entry(struct snd_info_entry *entry);
  113. int snd_info_store_text(struct snd_info_entry *entry);
  114. int snd_info_restore_text(struct snd_info_entry *entry);
  115. int snd_info_card_create(struct snd_card *card);
  116. int snd_info_card_register(struct snd_card *card);
  117. int snd_info_card_free(struct snd_card *card);
  118. void snd_info_card_disconnect(struct snd_card *card);
  119. void snd_info_card_id_change(struct snd_card *card);
  120. int snd_info_register(struct snd_info_entry *entry);
  121. /* for card drivers */
  122. int snd_card_proc_new(struct snd_card *card, const char *name,
  123. struct snd_info_entry **entryp);
  124. static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
  125. void *private_data,
  126. void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
  127. {
  128. entry->private_data = private_data;
  129. entry->c.text.read = read;
  130. }
  131. int snd_info_check_reserved_words(const char *str);
  132. #else
  133. #define snd_seq_root NULL
  134. #define snd_oss_root NULL
  135. static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; }
  136. static inline int snd_info_init(void) { return 0; }
  137. static inline int snd_info_done(void) { return 0; }
  138. static inline int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) { return 0; }
  139. static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
  140. static inline struct snd_info_entry *snd_info_create_module_entry(struct module *module, const char *name, struct snd_info_entry *parent) { return NULL; }
  141. static inline struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card, const char *name, struct snd_info_entry *parent) { return NULL; }
  142. static inline void snd_info_free_entry(struct snd_info_entry *entry) { ; }
  143. static inline int snd_info_card_create(struct snd_card *card) { return 0; }
  144. static inline int snd_info_card_register(struct snd_card *card) { return 0; }
  145. static inline int snd_info_card_free(struct snd_card *card) { return 0; }
  146. static inline void snd_info_card_disconnect(struct snd_card *card) { }
  147. static inline void snd_info_card_id_change(struct snd_card *card) { }
  148. static inline int snd_info_register(struct snd_info_entry *entry) { return 0; }
  149. static inline int snd_card_proc_new(struct snd_card *card, const char *name,
  150. struct snd_info_entry **entryp) { return -EINVAL; }
  151. static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
  152. void *private_data,
  153. void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
  154. static inline int snd_info_check_reserved_words(const char *str) { return 1; }
  155. #endif
  156. /*
  157. * OSS info part
  158. */
  159. #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
  160. #define SNDRV_OSS_INFO_DEV_AUDIO 0
  161. #define SNDRV_OSS_INFO_DEV_SYNTH 1
  162. #define SNDRV_OSS_INFO_DEV_MIDI 2
  163. #define SNDRV_OSS_INFO_DEV_TIMERS 4
  164. #define SNDRV_OSS_INFO_DEV_MIXERS 5
  165. #define SNDRV_OSS_INFO_DEV_COUNT 6
  166. int snd_oss_info_register(int dev, int num, char *string);
  167. #define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
  168. #endif /* CONFIG_SND_OSSEMUL && CONFIG_PROC_FS */
  169. #endif /* __SOUND_INFO_H */