info.h 7.0 KB

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