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