info.h 6.6 KB

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