info.h 7.0 KB

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