info.h 7.4 KB

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