info.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. int snd_info_check_reserved_words(const char *str);
  82. #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
  83. int snd_info_minor_register(void);
  84. int snd_info_minor_unregister(void);
  85. #else
  86. #define snd_info_minor_register() /* NOP */
  87. #define snd_info_minor_unregister() /* NOP */
  88. #endif
  89. #ifdef CONFIG_PROC_FS
  90. extern struct snd_info_entry *snd_seq_root;
  91. #ifdef CONFIG_SND_OSSEMUL
  92. extern struct snd_info_entry *snd_oss_root;
  93. #else
  94. #define snd_oss_root NULL
  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. int snd_info_register(struct snd_info_entry * entry);
  114. int snd_info_unregister(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. long read_size,
  120. void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
  121. {
  122. entry->private_data = private_data;
  123. entry->c.text.read_size = read_size;
  124. entry->c.text.read = read;
  125. }
  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. #define snd_card_proc_new(card,name,entryp) 0 /* always success */
  143. #define snd_info_set_text_ops(entry,private_data,read_size,read) /*NOP*/
  144. #endif
  145. /*
  146. * OSS info part
  147. */
  148. #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
  149. #define SNDRV_OSS_INFO_DEV_AUDIO 0
  150. #define SNDRV_OSS_INFO_DEV_SYNTH 1
  151. #define SNDRV_OSS_INFO_DEV_MIDI 2
  152. #define SNDRV_OSS_INFO_DEV_TIMERS 4
  153. #define SNDRV_OSS_INFO_DEV_MIXERS 5
  154. #define SNDRV_OSS_INFO_DEV_COUNT 6
  155. int snd_oss_info_register(int dev, int num, char *string);
  156. #define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
  157. #endif /* CONFIG_SND_OSSEMUL && CONFIG_PROC_FS */
  158. #endif /* __SOUND_INFO_H */