xref: /illumos-gate/usr/src/uts/common/sys/mixer.h (revision bbf21555)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
588447a05SGarrett D'Amore  * Common Development and Distribution License (the "License").
688447a05SGarrett D'Amore  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
2288447a05SGarrett D'Amore  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
2388447a05SGarrett D'Amore  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_MIXER_H
277c478bd9Sstevel@tonic-gate #define	_SYS_MIXER_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/audio.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #define	AM_MIXER_MODE			0
367c478bd9Sstevel@tonic-gate #define	AM_COMPAT_MODE			1
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #define	AM_DEFAULT_SAMPLERATE		8000
397c478bd9Sstevel@tonic-gate #define	AM_DEFAULT_CHANNELS		AUDIO_CHANNELS_MONO
407c478bd9Sstevel@tonic-gate #define	AM_DEFAULT_PRECISION		AUDIO_PRECISION_8
417c478bd9Sstevel@tonic-gate #define	AM_DEFAULT_ENCODING		AUDIO_ENCODING_ULAW
427c478bd9Sstevel@tonic-gate #define	AM_DEFAULT_GAIN			AUDIO_MID_GAIN
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
457c478bd9Sstevel@tonic-gate  * Mixer ioctls.
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate #define	MIOC				('M'<<8)
487c478bd9Sstevel@tonic-gate #define	AUDIO_MIXER_MULTIPLE_OPEN	(MIOC|10)
497c478bd9Sstevel@tonic-gate #define	AUDIO_MIXER_SINGLE_OPEN		(MIOC|11)
507c478bd9Sstevel@tonic-gate #define	AUDIO_MIXER_GET_SAMPLE_RATES	(MIOC|12)
517c478bd9Sstevel@tonic-gate #define	AUDIO_MIXERCTL_GETINFO		(MIOC|13)
527c478bd9Sstevel@tonic-gate #define	AUDIO_MIXERCTL_SETINFO		(MIOC|14)
537c478bd9Sstevel@tonic-gate #define	AUDIO_MIXERCTL_GET_CHINFO	(MIOC|15)
547c478bd9Sstevel@tonic-gate #define	AUDIO_MIXERCTL_SET_CHINFO	(MIOC|16)
557c478bd9Sstevel@tonic-gate #define	AUDIO_MIXERCTL_GET_MODE		(MIOC|17)
567c478bd9Sstevel@tonic-gate #define	AUDIO_MIXERCTL_SET_MODE		(MIOC|18)
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate #define	AUDIO_MIXER_CTL_STRUCT_SIZE(num_ch)	(sizeof (am_control_t) + \
597c478bd9Sstevel@tonic-gate 					((num_ch - 1) * sizeof (int8_t)))
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate #define	AUDIO_MIXER_SAMP_RATES_STRUCT_SIZE(num_srs)		\
627c478bd9Sstevel@tonic-gate 					(sizeof (am_sample_rates_t) + \
637c478bd9Sstevel@tonic-gate 					((num_srs - 1) * sizeof (uint_t)))
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate /*
667c478bd9Sstevel@tonic-gate  * Mixer software features
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate #define	AM_MIXER			0x00000001	/* audio mixer */
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * am_control_t		- structure that holds information on the audio device
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate struct am_control {
747c478bd9Sstevel@tonic-gate 	/*
757c478bd9Sstevel@tonic-gate 	 * Because a particular channel may be virtual, it isn't possible
767c478bd9Sstevel@tonic-gate 	 * to use the normal ioctl()s to set the some of the hardware's state.
777c478bd9Sstevel@tonic-gate 	 * Only the dev_info structure's play/record gain, balance, port, and
787c478bd9Sstevel@tonic-gate 	 * pause members, as well as the monitor_gain and output_muted members
797c478bd9Sstevel@tonic-gate 	 * may be modified.
807c478bd9Sstevel@tonic-gate 	 */
817c478bd9Sstevel@tonic-gate 	audio_info_t	dev_info;
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate 	/*
84*bbf21555SRichard Lowe 	 * The mixer(4I) manual page shows an example of using the ch_open[]
857c478bd9Sstevel@tonic-gate 	 * array. Each element that is set to 0 represents a channel which
867c478bd9Sstevel@tonic-gate 	 * isn't allocated, and non-zero elements represent a channel that is
877c478bd9Sstevel@tonic-gate 	 * alloacted. This size of this array may change, depending on the
887c478bd9Sstevel@tonic-gate 	 * number of channels the audiosup module allocates per device.
897c478bd9Sstevel@tonic-gate 	 */
907c478bd9Sstevel@tonic-gate 	int8_t		ch_open[1];
917c478bd9Sstevel@tonic-gate };
927c478bd9Sstevel@tonic-gate typedef struct am_control am_control_t;
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * am_sample_rates_t	- structure for a list of supported sample rates
967c478bd9Sstevel@tonic-gate  */
977c478bd9Sstevel@tonic-gate struct am_sample_rates {
987c478bd9Sstevel@tonic-gate 	/*
997c478bd9Sstevel@tonic-gate 	 * Set this to AUIDO_PLAY or AUDIO_RECORD, but not both, to get
1007c478bd9Sstevel@tonic-gate 	 * the play or record sample rates, respectively.
1017c478bd9Sstevel@tonic-gate 	 */
1027c478bd9Sstevel@tonic-gate 	uint_t		type;
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 	/*
1057c478bd9Sstevel@tonic-gate 	 * Some devices support a complete range of sample rates between the
1067c478bd9Sstevel@tonic-gate 	 * two provided in the samp_rates[] array. If this is so then this
1077c478bd9Sstevel@tonic-gate 	 * flag is set to MIXER_SR_LIMITS when AUDIO_MIXER_GET_SAMPLE_RATES
1087c478bd9Sstevel@tonic-gate 	 * returns this structure.
1097c478bd9Sstevel@tonic-gate 	 */
1107c478bd9Sstevel@tonic-gate 	uint_t		flags;
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 	/*
1137c478bd9Sstevel@tonic-gate 	 * Set this number to the number of sample rates to request. The
114*bbf21555SRichard Lowe 	 * mixer(4I) manual page shows an example of using this structure.
1157c478bd9Sstevel@tonic-gate 	 * When AUDIO_MIXER_GET_SAMPLE_RATES returns the number of samples
1167c478bd9Sstevel@tonic-gate 	 * available is set. This may be more or less than the number requested.
1177c478bd9Sstevel@tonic-gate 	 * If more that only the requested number of samples is arctually
1187c478bd9Sstevel@tonic-gate 	 * returned in the samp_rates array.
1197c478bd9Sstevel@tonic-gate 	 */
1207c478bd9Sstevel@tonic-gate 	uint_t		num_samp_rates;
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate 	/*
1237c478bd9Sstevel@tonic-gate 	 * Variable size array for the supported sample rates. See the example
124*bbf21555SRichard Lowe 	 * in the mixer(4I) manual page for how to use this array.
1257c478bd9Sstevel@tonic-gate 	 */
1267c478bd9Sstevel@tonic-gate 	uint_t		samp_rates[1];
1277c478bd9Sstevel@tonic-gate };
1287c478bd9Sstevel@tonic-gate typedef struct am_sample_rates am_sample_rates_t;
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate /* am_sample_rates.flags defines */
1317c478bd9Sstevel@tonic-gate #define	MIXER_SR_LIMITS		0x00000001u	/* sample rates set limits */
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1347c478bd9Sstevel@tonic-gate }
1357c478bd9Sstevel@tonic-gate #endif
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate #endif	/* _SYS_MIXER_H */
138