2019-05-27 14:55:05 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifndef __SOUND_INFO_H
|
|
|
|
#define __SOUND_INFO_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Header file for info interface
|
2007-10-15 15:50:19 +08:00
|
|
|
* Copyright (c) by Jaroslav Kysela <perex@perex.cz>
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/poll.h>
|
2015-04-22 22:10:22 +08:00
|
|
|
#include <linux/seq_file.h>
|
2015-04-23 00:26:38 +08:00
|
|
|
#include <sound/core.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* buffer for information */
|
|
|
|
struct snd_info_buffer {
|
|
|
|
char *buffer; /* pointer to begin of buffer */
|
2006-04-28 21:13:40 +08:00
|
|
|
unsigned int curr; /* current position in buffer */
|
|
|
|
unsigned int size; /* current size */
|
|
|
|
unsigned int len; /* total length of buffer */
|
2005-04-17 06:20:36 +08:00
|
|
|
int stop; /* stop flag */
|
|
|
|
int error; /* error code */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SNDRV_INFO_CONTENT_TEXT 0
|
|
|
|
#define SNDRV_INFO_CONTENT_DATA 1
|
|
|
|
|
|
|
|
struct snd_info_entry;
|
|
|
|
|
|
|
|
struct snd_info_entry_text {
|
2008-11-12 23:53:47 +08:00
|
|
|
void (*read)(struct snd_info_entry *entry,
|
|
|
|
struct snd_info_buffer *buffer);
|
|
|
|
void (*write)(struct snd_info_entry *entry,
|
|
|
|
struct snd_info_buffer *buffer);
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct snd_info_entry_ops {
|
2008-11-12 23:53:47 +08:00
|
|
|
int (*open)(struct snd_info_entry *entry,
|
|
|
|
unsigned short mode, void **file_private_data);
|
|
|
|
int (*release)(struct snd_info_entry *entry,
|
|
|
|
unsigned short mode, void *file_private_data);
|
2010-04-13 17:22:01 +08:00
|
|
|
ssize_t (*read)(struct snd_info_entry *entry, void *file_private_data,
|
|
|
|
struct file *file, char __user *buf,
|
|
|
|
size_t count, loff_t pos);
|
|
|
|
ssize_t (*write)(struct snd_info_entry *entry, void *file_private_data,
|
|
|
|
struct file *file, const char __user *buf,
|
|
|
|
size_t count, loff_t pos);
|
|
|
|
loff_t (*llseek)(struct snd_info_entry *entry,
|
|
|
|
void *file_private_data, struct file *file,
|
|
|
|
loff_t offset, int orig);
|
2017-07-03 10:22:01 +08:00
|
|
|
__poll_t (*poll)(struct snd_info_entry *entry,
|
2010-04-13 17:22:01 +08:00
|
|
|
void *file_private_data, struct file *file,
|
|
|
|
poll_table *wait);
|
2008-11-12 23:53:47 +08:00
|
|
|
int (*ioctl)(struct snd_info_entry *entry, void *file_private_data,
|
|
|
|
struct file *file, unsigned int cmd, unsigned long arg);
|
|
|
|
int (*mmap)(struct snd_info_entry *entry, void *file_private_data,
|
|
|
|
struct inode *inode, struct file *file,
|
|
|
|
struct vm_area_struct *vma);
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct snd_info_entry {
|
|
|
|
const char *name;
|
2011-07-24 15:36:29 +08:00
|
|
|
umode_t mode;
|
2005-04-17 06:20:36 +08:00
|
|
|
long size;
|
|
|
|
unsigned short content;
|
|
|
|
union {
|
|
|
|
struct snd_info_entry_text text;
|
2020-01-03 16:16:44 +08:00
|
|
|
const struct snd_info_entry_ops *ops;
|
2005-04-17 06:20:36 +08:00
|
|
|
} c;
|
2005-11-17 20:58:48 +08:00
|
|
|
struct snd_info_entry *parent;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct module *module;
|
|
|
|
void *private_data;
|
2005-11-17 20:58:48 +08:00
|
|
|
void (*private_free)(struct snd_info_entry *entry);
|
2005-04-17 06:20:36 +08:00
|
|
|
struct proc_dir_entry *p;
|
2006-01-16 23:29:08 +08:00
|
|
|
struct mutex access;
|
2006-06-23 20:37:59 +08:00
|
|
|
struct list_head children;
|
|
|
|
struct list_head list;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2015-05-27 19:45:45 +08:00
|
|
|
#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)
|
2005-11-17 20:58:48 +08:00
|
|
|
int snd_info_minor_register(void);
|
2005-04-17 06:20:36 +08:00
|
|
|
#else
|
2015-04-23 16:56:21 +08:00
|
|
|
#define snd_info_minor_register() 0
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2015-05-27 19:45:45 +08:00
|
|
|
#ifdef CONFIG_SND_PROC_FS
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-11-17 20:58:48 +08:00
|
|
|
extern struct snd_info_entry *snd_seq_root;
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_SND_OSSEMUL
|
2005-11-17 20:58:48 +08:00
|
|
|
extern struct snd_info_entry *snd_oss_root;
|
2007-12-14 19:58:45 +08:00
|
|
|
void snd_card_info_read_oss(struct snd_info_buffer *buffer);
|
2005-04-17 06:20:36 +08:00
|
|
|
#else
|
|
|
|
#define snd_oss_root NULL
|
2007-12-14 19:58:45 +08:00
|
|
|
static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
2015-04-22 22:10:22 +08:00
|
|
|
/**
|
|
|
|
* snd_iprintf - printf on the procfs buffer
|
|
|
|
* @buf: the procfs buffer
|
|
|
|
* @fmt: the printf format
|
|
|
|
*
|
|
|
|
* Outputs the string on the procfs buffer just like printf().
|
|
|
|
*
|
|
|
|
* Return: zero for success, or a negative error code.
|
|
|
|
*/
|
|
|
|
#define snd_iprintf(buf, fmt, args...) \
|
|
|
|
seq_printf((struct seq_file *)(buf)->buffer, fmt, ##args)
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
int snd_info_init(void);
|
|
|
|
int snd_info_done(void);
|
|
|
|
|
2008-11-12 23:53:47 +08:00
|
|
|
int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len);
|
2009-09-08 20:29:58 +08:00
|
|
|
const char *snd_info_get_str(char *dest, const char *src, int len);
|
2008-11-12 23:53:47 +08:00
|
|
|
struct snd_info_entry *snd_info_create_module_entry(struct module *module,
|
2005-04-17 06:20:36 +08:00
|
|
|
const char *name,
|
2008-11-12 23:53:47 +08:00
|
|
|
struct snd_info_entry *parent);
|
|
|
|
struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card,
|
2005-04-17 06:20:36 +08:00
|
|
|
const char *name,
|
2008-11-12 23:53:47 +08:00
|
|
|
struct snd_info_entry *parent);
|
|
|
|
void snd_info_free_entry(struct snd_info_entry *entry);
|
|
|
|
int snd_info_store_text(struct snd_info_entry *entry);
|
|
|
|
int snd_info_restore_text(struct snd_info_entry *entry);
|
|
|
|
|
|
|
|
int snd_info_card_create(struct snd_card *card);
|
|
|
|
int snd_info_card_register(struct snd_card *card);
|
|
|
|
int snd_info_card_free(struct snd_card *card);
|
|
|
|
void snd_info_card_disconnect(struct snd_card *card);
|
|
|
|
void snd_info_card_id_change(struct snd_card *card);
|
|
|
|
int snd_info_register(struct snd_info_entry *entry);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* for card drivers */
|
2015-04-23 00:26:38 +08:00
|
|
|
static inline int snd_card_proc_new(struct snd_card *card, const char *name,
|
|
|
|
struct snd_info_entry **entryp)
|
|
|
|
{
|
|
|
|
*entryp = snd_info_create_card_entry(card, name, card->proc_root);
|
|
|
|
return *entryp ? 0 : -ENOMEM;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-11-17 20:58:48 +08:00
|
|
|
static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
|
2008-11-12 23:53:47 +08:00
|
|
|
void *private_data,
|
|
|
|
void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
entry->private_data = private_data;
|
|
|
|
entry->c.text.read = read;
|
|
|
|
}
|
|
|
|
|
2019-02-04 21:53:04 +08:00
|
|
|
int snd_card_rw_proc_new(struct snd_card *card, const char *name,
|
|
|
|
void *private_data,
|
|
|
|
void (*read)(struct snd_info_entry *,
|
|
|
|
struct snd_info_buffer *),
|
|
|
|
void (*write)(struct snd_info_entry *entry,
|
|
|
|
struct snd_info_buffer *buffer));
|
|
|
|
|
2005-12-01 17:42:42 +08:00
|
|
|
int snd_info_check_reserved_words(const char *str);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define snd_seq_root NULL
|
|
|
|
#define snd_oss_root NULL
|
|
|
|
|
2008-11-12 23:53:47 +08:00
|
|
|
static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; }
|
2005-04-17 06:20:36 +08:00
|
|
|
static inline int snd_info_init(void) { return 0; }
|
|
|
|
static inline int snd_info_done(void) { return 0; }
|
|
|
|
|
2008-11-12 23:53:47 +08:00
|
|
|
static inline int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) { return 0; }
|
2005-04-17 06:20:36 +08:00
|
|
|
static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
|
2008-11-12 23:53:47 +08:00
|
|
|
static inline struct snd_info_entry *snd_info_create_module_entry(struct module *module, const char *name, struct snd_info_entry *parent) { return NULL; }
|
|
|
|
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; }
|
|
|
|
static inline void snd_info_free_entry(struct snd_info_entry *entry) { ; }
|
|
|
|
|
|
|
|
static inline int snd_info_card_create(struct snd_card *card) { return 0; }
|
|
|
|
static inline int snd_info_card_register(struct snd_card *card) { return 0; }
|
|
|
|
static inline int snd_info_card_free(struct snd_card *card) { return 0; }
|
|
|
|
static inline void snd_info_card_disconnect(struct snd_card *card) { }
|
|
|
|
static inline void snd_info_card_id_change(struct snd_card *card) { }
|
|
|
|
static inline int snd_info_register(struct snd_info_entry *entry) { return 0; }
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-12-01 17:42:42 +08:00
|
|
|
static inline int snd_card_proc_new(struct snd_card *card, const char *name,
|
|
|
|
struct snd_info_entry **entryp) { return -EINVAL; }
|
|
|
|
static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
|
|
|
|
void *private_data,
|
|
|
|
void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
|
2019-02-04 21:53:04 +08:00
|
|
|
static inline int snd_card_rw_proc_new(struct snd_card *card, const char *name,
|
|
|
|
void *private_data,
|
|
|
|
void (*read)(struct snd_info_entry *,
|
|
|
|
struct snd_info_buffer *),
|
|
|
|
void (*write)(struct snd_info_entry *entry,
|
|
|
|
struct snd_info_buffer *buffer))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2005-12-01 17:42:42 +08:00
|
|
|
static inline int snd_info_check_reserved_words(const char *str) { return 1; }
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2019-02-04 21:53:04 +08:00
|
|
|
/**
|
|
|
|
* snd_card_ro_proc_new - Create a read-only text proc file entry for the card
|
|
|
|
* @card: the card instance
|
|
|
|
* @name: the file name
|
|
|
|
* @private_data: the arbitrary private data
|
|
|
|
* @read: the read callback
|
|
|
|
*
|
|
|
|
* This proc file entry will be registered via snd_card_register() call, and
|
|
|
|
* it will be removed automatically at the card removal, too.
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
snd_card_ro_proc_new(struct snd_card *card, const char *name,
|
|
|
|
void *private_data,
|
|
|
|
void (*read)(struct snd_info_entry *,
|
|
|
|
struct snd_info_buffer *))
|
|
|
|
{
|
|
|
|
return snd_card_rw_proc_new(card, name, private_data, read, NULL);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* OSS info part
|
|
|
|
*/
|
|
|
|
|
2015-05-27 19:45:45 +08:00
|
|
|
#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define SNDRV_OSS_INFO_DEV_AUDIO 0
|
|
|
|
#define SNDRV_OSS_INFO_DEV_SYNTH 1
|
|
|
|
#define SNDRV_OSS_INFO_DEV_MIDI 2
|
|
|
|
#define SNDRV_OSS_INFO_DEV_TIMERS 4
|
|
|
|
#define SNDRV_OSS_INFO_DEV_MIXERS 5
|
|
|
|
|
|
|
|
#define SNDRV_OSS_INFO_DEV_COUNT 6
|
|
|
|
|
2005-11-17 20:58:48 +08:00
|
|
|
int snd_oss_info_register(int dev, int num, char *string);
|
2005-04-17 06:20:36 +08:00
|
|
|
#define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
|
|
|
|
|
2015-05-27 19:45:45 +08:00
|
|
|
#endif /* CONFIG_SND_OSSEMUL && CONFIG_SND_PROC_FS */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#endif /* __SOUND_INFO_H */
|