diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2020-02-26 13:53:59 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2020-02-26 13:53:59 +0000 |
commit | aecb8e198594ee032277b784712935eb10fc4708 (patch) | |
tree | 92ab6418cfec5c32da4c9feafc252332c85fa7b4 /include | |
parent | 7d9906cf5784b21f9d2afab98129af86715d51d8 (diff) |
Add API to control audio device parameters exposed by sndiod.
The API exposes controls of modern audio hardware and sndiod software
volume knobs in a uniform way. Hardware knobs are exposed through
sndiod. Multiple programs may use the controls at the same time
without the need to continuously scan the controls.
For now sndiod exposes only its own controls and the master output and
input volumes of the underlying hardware (if any), i.e. those
typically exposed by acpi volume keys.
ok deraadt
Diffstat (limited to 'include')
-rw-r--r-- | include/sndio.h | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/include/sndio.h b/include/sndio.h index dcb9ddfbb19..4fed3d5c2d1 100644 --- a/include/sndio.h +++ b/include/sndio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sndio.h,v 1.9 2015/12/20 11:29:29 ratchov Exp $ */ +/* $OpenBSD: sndio.h,v 1.10 2020/02/26 13:53:58 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -26,10 +26,16 @@ #define MIO_PORTANY "default" /* + * limits + */ +#define SIOCTL_NAMEMAX 12 /* max name length */ + +/* * private ``handle'' structure */ struct sio_hdl; struct mio_hdl; +struct sioctl_hdl; /* * parameters of a full-duplex stream @@ -85,12 +91,41 @@ struct sio_cap { #define SIO_XSTRINGS { "ignore", "sync", "error" } /* + * controlled component of the device + */ +struct sioctl_node { + char name[SIOCTL_NAMEMAX]; /* ex. "spkr" */ + int unit; /* optional number or -1 */ +}; + +/* + * description of a control (index, value) pair + */ +struct sioctl_desc { + unsigned int addr; /* control address */ +#define SIOCTL_NONE 0 /* deleted */ +#define SIOCTL_NUM 2 /* integer in the 0..127 range */ +#define SIOCTL_SW 3 /* on/off switch (0 or 1) */ +#define SIOCTL_VEC 4 /* number, element of vector */ +#define SIOCTL_LIST 5 /* switch, element of a list */ + unsigned int type; /* one of above */ + char func[SIOCTL_NAMEMAX]; /* function name, ex. "level" */ + char group[SIOCTL_NAMEMAX]; /* group this control belongs to */ + struct sioctl_node node0; /* affected node */ + struct sioctl_node node1; /* dito for SIOCTL_{VEC,LIST} */ + unsigned int maxval; /* max value for SIOCTL_{NUM,VEC} */ + int __pad[3]; +}; + +/* * mode bitmap */ #define SIO_PLAY 1 #define SIO_REC 2 #define MIO_OUT 4 #define MIO_IN 8 +#define SIOCTL_READ 0x100 +#define SIOCTL_WRITE 0x200 /* * default bytes per sample for the given bits per sample @@ -144,10 +179,24 @@ int mio_pollfd(struct mio_hdl *, struct pollfd *, int); int mio_revents(struct mio_hdl *, struct pollfd *); int mio_eof(struct mio_hdl *); +struct sioctl_hdl *sioctl_open(const char *, unsigned int, int); +void sioctl_close(struct sioctl_hdl *); +int sioctl_ondesc(struct sioctl_hdl *, + void (*)(void *, struct sioctl_desc *, int), void *); +int sioctl_onval(struct sioctl_hdl *, + void (*)(void *, unsigned int, unsigned int), void *); +int sioctl_setval(struct sioctl_hdl *, unsigned int, unsigned int); +int sioctl_nfds(struct sioctl_hdl *); +int sioctl_pollfd(struct sioctl_hdl *, struct pollfd *, int); +int sioctl_revents(struct sioctl_hdl *, struct pollfd *); +int sioctl_eof(struct sioctl_hdl *); + int mio_rmidi_getfd(const char *, unsigned int, int); struct mio_hdl *mio_rmidi_fdopen(int, unsigned int, int); int sio_sun_getfd(const char *, unsigned int, int); struct sio_hdl *sio_sun_fdopen(int, unsigned int, int); +int sioctl_sun_getfd(const char *, unsigned int, int); +struct sioctl_hdl *sioctl_sun_fdopen(int, unsigned int, int); #ifdef __cplusplus } |