2021-03-10 20:06:24 +01:00
|
|
|
#include <stdbool.h>
|
2021-03-07 19:58:33 +01:00
|
|
|
#include <alsa/asoundlib.h>
|
|
|
|
|
2022-02-02 15:31:33 +01:00
|
|
|
#define LOCK_TIMEOUT 10
|
|
|
|
|
2005-05-10 12:55:24 +02:00
|
|
|
extern int debugflag;
|
|
|
|
extern int force_restore;
|
2008-09-18 09:40:02 +02:00
|
|
|
extern int ignore_nocards;
|
2013-04-05 11:51:51 +02:00
|
|
|
extern int do_lock;
|
|
|
|
extern int use_syslog;
|
2005-05-10 12:55:24 +02:00
|
|
|
extern char *command;
|
2008-08-14 16:46:27 +02:00
|
|
|
extern char *statefile;
|
2022-02-02 15:31:33 +01:00
|
|
|
extern char *lockpath;
|
2014-05-07 11:13:41 +02:00
|
|
|
extern char *lockfile;
|
2005-05-10 12:55:24 +02:00
|
|
|
|
2021-03-10 20:06:24 +01:00
|
|
|
struct snd_card_iterator {
|
|
|
|
int card;
|
|
|
|
char name[16];
|
|
|
|
bool single;
|
|
|
|
bool first;
|
|
|
|
};
|
|
|
|
|
2013-04-05 11:51:51 +02:00
|
|
|
void info_(const char *fcn, long line, const char *fmt, ...);
|
|
|
|
void error_(const char *fcn, long line, const char *fmt, ...);
|
|
|
|
void cerror_(const char *fcn, long line, int cond, const char *fmt, ...);
|
|
|
|
void dbg_(const char *fcn, long line, const char *fmt, ...);
|
2020-05-14 19:09:45 +02:00
|
|
|
void error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...);
|
2008-08-14 16:46:27 +02:00
|
|
|
|
2008-07-31 15:45:08 +02:00
|
|
|
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
|
2020-02-05 09:12:18 +01:00
|
|
|
#define info(...) do { info_(__func__, __LINE__, __VA_ARGS__); } while (0)
|
|
|
|
#define error(...) do { error_(__func__, __LINE__, __VA_ARGS__); } while (0)
|
|
|
|
#define cerror(cond, ...) do { cerror_(__func__, __LINE__, (cond) != 0, __VA_ARGS__); } while (0)
|
|
|
|
#define dbg(...) do { dbg_(__func__, __LINE__, __VA_ARGS__); } while (0)
|
2008-07-31 15:45:08 +02:00
|
|
|
#else
|
2020-02-05 09:12:18 +01:00
|
|
|
#define info(args...) do { info_(__func__, __LINE__, ##args); } while (0)
|
|
|
|
#define error(args...) do { error_(__func__, __LINE__, ##args); } while (0)
|
|
|
|
#define cerror(cond, ...) do { error_(__func__, __LINE__, (cond) != 0, ##args); } while (0)
|
|
|
|
#define dbg(args...) do { dbg_(__func__, __LINE__, ##args); } while (0)
|
2008-07-31 15:45:08 +02:00
|
|
|
#endif
|
|
|
|
|
2020-10-02 05:45:43 +02:00
|
|
|
#define FLAG_UCM_DISABLED (1<<0)
|
2021-03-10 19:26:51 +01:00
|
|
|
#define FLAG_UCM_FBOOT (1<<1)
|
|
|
|
#define FLAG_UCM_BOOT (1<<2)
|
|
|
|
#define FLAG_UCM_DEFAULTS (1<<3)
|
2021-10-28 12:07:10 +02:00
|
|
|
#define FLAG_UCM_NODEV (1<<4)
|
2020-05-14 19:34:18 +02:00
|
|
|
|
2021-03-10 20:06:24 +01:00
|
|
|
void snd_card_iterator_init(struct snd_card_iterator *iter, int cardno);
|
|
|
|
int snd_card_iterator_sinit(struct snd_card_iterator *iter, const char *cardname);
|
|
|
|
const char *snd_card_iterator_next(struct snd_card_iterator *iter);
|
|
|
|
int snd_card_iterator_error(struct snd_card_iterator *iter);
|
|
|
|
|
2021-03-07 19:58:33 +01:00
|
|
|
int load_configuration(const char *file, snd_config_t **top, int *open_failed);
|
2021-04-13 11:15:55 +02:00
|
|
|
int init(const char *cfgdir, const char *file, int flags, const char *cardname);
|
2020-05-14 19:34:18 +02:00
|
|
|
int init_ucm(int flags, int cardno);
|
2014-09-24 10:35:53 +02:00
|
|
|
int state_lock(const char *file, int timeout);
|
2022-02-02 15:31:33 +01:00
|
|
|
int state_unlock(int lock_fd, const char *file);
|
|
|
|
int card_lock(int card_number, int timeout);
|
|
|
|
int card_unlock(int lock_fd, int card_number);
|
2005-05-10 12:55:24 +02:00
|
|
|
int save_state(const char *file, const char *cardname);
|
2021-04-13 11:15:55 +02:00
|
|
|
int load_state(const char *cfgdir, const char *file,
|
|
|
|
const char *initfile, int initflags,
|
2020-05-14 19:34:18 +02:00
|
|
|
const char *cardname, int do_init);
|
2005-05-10 12:55:24 +02:00
|
|
|
int power(const char *argv[], int argc);
|
2014-09-24 10:46:02 +02:00
|
|
|
int monitor(const char *name);
|
2022-05-09 09:34:22 +02:00
|
|
|
int general_info(const char *name);
|
2013-04-05 11:51:51 +02:00
|
|
|
int state_daemon(const char *file, const char *cardname, int period,
|
|
|
|
const char *pidfile);
|
|
|
|
int state_daemon_kill(const char *pidfile, const char *cmd);
|
2021-02-26 19:28:03 +01:00
|
|
|
int clean(const char *cardname, char *const *extra_args);
|
2021-04-13 11:15:55 +02:00
|
|
|
int snd_card_clean_cfgdir(const char *cfgdir, int cardno);
|
2008-07-31 15:45:08 +02:00
|
|
|
|
|
|
|
/* utils */
|
|
|
|
|
|
|
|
int file_map(const char *filename, char **buf, size_t *bufsize);
|
|
|
|
void file_unmap(void *buf, size_t bufsize);
|
|
|
|
size_t line_width(const char *buf, size_t bufsize, size_t pos);
|
2010-05-26 10:37:58 +02:00
|
|
|
void initfailed(int cardnumber, const char *reason, int exitcode);
|
2008-07-31 15:45:08 +02:00
|
|
|
|
|
|
|
static inline int hextodigit(int c)
|
|
|
|
{
|
|
|
|
if (c >= '0' && c <= '9')
|
|
|
|
c -= '0';
|
|
|
|
else if (c >= 'a' && c <= 'f')
|
|
|
|
c = c - 'a' + 10;
|
|
|
|
else if (c >= 'A' && c <= 'F')
|
|
|
|
c = c - 'A' + 10;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
return c;
|
|
|
|
}
|
2013-04-05 13:42:15 +02:00
|
|
|
|
|
|
|
#define ARRAY_SIZE(a) (sizeof (a) / sizeof (a)[0])
|