xref: /illumos-gate/usr/src/uts/common/sys/mixer.h (revision e3ae4b35c024af1196582063ecee3ab79367227d)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_MIXER_H
27 #define	_SYS_MIXER_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/audio.h>
34 
35 #define	AM_MIXER_MODE			0
36 #define	AM_COMPAT_MODE			1
37 
38 #define	AM_DEFAULT_SAMPLERATE		8000
39 #define	AM_DEFAULT_CHANNELS		AUDIO_CHANNELS_MONO
40 #define	AM_DEFAULT_PRECISION		AUDIO_PRECISION_8
41 #define	AM_DEFAULT_ENCODING		AUDIO_ENCODING_ULAW
42 #define	AM_DEFAULT_GAIN			AUDIO_MID_GAIN
43 
44 /*
45  * Mixer ioctls.
46  */
47 #define	MIOC				('M'<<8)
48 #define	AUDIO_MIXER_MULTIPLE_OPEN	(MIOC|10)
49 #define	AUDIO_MIXER_SINGLE_OPEN		(MIOC|11)
50 #define	AUDIO_MIXER_GET_SAMPLE_RATES	(MIOC|12)
51 #define	AUDIO_MIXERCTL_GETINFO		(MIOC|13)
52 #define	AUDIO_MIXERCTL_SETINFO		(MIOC|14)
53 #define	AUDIO_MIXERCTL_GET_CHINFO	(MIOC|15)
54 #define	AUDIO_MIXERCTL_SET_CHINFO	(MIOC|16)
55 #define	AUDIO_MIXERCTL_GET_MODE		(MIOC|17)
56 #define	AUDIO_MIXERCTL_SET_MODE		(MIOC|18)
57 
58 #define	AUDIO_MIXER_CTL_STRUCT_SIZE(num_ch)	(sizeof (am_control_t) + \
59 					((num_ch - 1) * sizeof (int8_t)))
60 
61 #define	AUDIO_MIXER_SAMP_RATES_STRUCT_SIZE(num_srs)		\
62 					(sizeof (am_sample_rates_t) + \
63 					((num_srs - 1) * sizeof (uint_t)))
64 
65 /*
66  * Mixer software features
67  */
68 #define	AM_MIXER			0x00000001	/* audio mixer */
69 
70 /*
71  * am_control_t		- structure that holds information on the audio device
72  */
73 struct am_control {
74 	/*
75 	 * Because a particular channel may be virtual, it isn't possible
76 	 * to use the normal ioctl()s to set the some of the hardware's state.
77 	 * Only the dev_info structure's play/record gain, balance, port, and
78 	 * pause members, as well as the monitor_gain and output_muted members
79 	 * may be modified.
80 	 */
81 	audio_info_t	dev_info;
82 
83 	/*
84 	 * The mixer(4I) manual page shows an example of using the ch_open[]
85 	 * array. Each element that is set to 0 represents a channel which
86 	 * isn't allocated, and non-zero elements represent a channel that is
87 	 * alloacted. This size of this array may change, depending on the
88 	 * number of channels the audiosup module allocates per device.
89 	 */
90 	int8_t		ch_open[1];
91 };
92 typedef struct am_control am_control_t;
93 
94 /*
95  * am_sample_rates_t	- structure for a list of supported sample rates
96  */
97 struct am_sample_rates {
98 	/*
99 	 * Set this to AUIDO_PLAY or AUDIO_RECORD, but not both, to get
100 	 * the play or record sample rates, respectively.
101 	 */
102 	uint_t		type;
103 
104 	/*
105 	 * Some devices support a complete range of sample rates between the
106 	 * two provided in the samp_rates[] array. If this is so then this
107 	 * flag is set to MIXER_SR_LIMITS when AUDIO_MIXER_GET_SAMPLE_RATES
108 	 * returns this structure.
109 	 */
110 	uint_t		flags;
111 
112 	/*
113 	 * Set this number to the number of sample rates to request. The
114 	 * mixer(4I) manual page shows an example of using this structure.
115 	 * When AUDIO_MIXER_GET_SAMPLE_RATES returns the number of samples
116 	 * available is set. This may be more or less than the number requested.
117 	 * If more that only the requested number of samples is arctually
118 	 * returned in the samp_rates array.
119 	 */
120 	uint_t		num_samp_rates;
121 
122 	/*
123 	 * Variable size array for the supported sample rates. See the example
124 	 * in the mixer(4I) manual page for how to use this array.
125 	 */
126 	uint_t		samp_rates[1];
127 };
128 typedef struct am_sample_rates am_sample_rates_t;
129 
130 /* am_sample_rates.flags defines */
131 #define	MIXER_SR_LIMITS		0x00000001u	/* sample rates set limits */
132 
133 #ifdef	__cplusplus
134 }
135 #endif
136 
137 #endif	/* _SYS_MIXER_H */
138