xref: /titanic_41/usr/src/cmd/audio/include/audio_device.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1992-2001 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _MULTIMEDIA_AUDIO_DEVICE_H
28*7c478bd9Sstevel@tonic-gate #define	_MULTIMEDIA_AUDIO_DEVICE_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
37*7c478bd9Sstevel@tonic-gate #include <sys/ioccom.h>
38*7c478bd9Sstevel@tonic-gate #include <sys/audioio.h>
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate typedef audio_info_t	Audio_info;
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate /*
43*7c478bd9Sstevel@tonic-gate  * The following macros read the current audio device configuration
44*7c478bd9Sstevel@tonic-gate  * and convert the data encoding format into an Audio_hdr.
45*7c478bd9Sstevel@tonic-gate  * 'F' is an open audio file descriptor.
46*7c478bd9Sstevel@tonic-gate  * 'H' is a pointer to an Audio_hdr.
47*7c478bd9Sstevel@tonic-gate  * The structure '*H' is updated after the device state has been read.
48*7c478bd9Sstevel@tonic-gate  */
49*7c478bd9Sstevel@tonic-gate #define	audio_get_play_config(F, H)					\
50*7c478bd9Sstevel@tonic-gate 		audio__setplayhdr((F), (H), AUDIO__PLAY)
51*7c478bd9Sstevel@tonic-gate #define	audio_get_record_config(F, H)					\
52*7c478bd9Sstevel@tonic-gate 		audio__setplayhdr((F), (H), AUDIO__RECORD)
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate /*
55*7c478bd9Sstevel@tonic-gate  * The following macros attempt to reconfigure the audio device so that
56*7c478bd9Sstevel@tonic-gate  * it operates on data encoded according to a given Audio_hdr.
57*7c478bd9Sstevel@tonic-gate  * 'F' is an open audio file descriptor.
58*7c478bd9Sstevel@tonic-gate  * 'H' is a pointer to an Audio_hdr describing the desired encoding.
59*7c478bd9Sstevel@tonic-gate  * The structure '*H' is updated after the device state has been read
60*7c478bd9Sstevel@tonic-gate  * to reflect the actual state of the device.
61*7c478bd9Sstevel@tonic-gate  *
62*7c478bd9Sstevel@tonic-gate  * AUDIO_SUCCESS is returned if the device configuration matches the
63*7c478bd9Sstevel@tonic-gate  * requested encoding.  AUDIO_ERR_NOEFFECT is returned if it does not.
64*7c478bd9Sstevel@tonic-gate  */
65*7c478bd9Sstevel@tonic-gate #define	audio_set_play_config(F, H)					\
66*7c478bd9Sstevel@tonic-gate 		audio__setplayhdr((F), (H), AUDIO__SET|AUDIO__PLAY)
67*7c478bd9Sstevel@tonic-gate #define	audio_set_record_config(F, H)					\
68*7c478bd9Sstevel@tonic-gate 		audio__setplayhdr((F), (H), AUDIO__SET|AUDIO__RECORD)
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate /*
72*7c478bd9Sstevel@tonic-gate  * The following macros pause or resume the audio play and/or record channels.
73*7c478bd9Sstevel@tonic-gate  * Note that requests to pause a channel that is not open will have no effect.
74*7c478bd9Sstevel@tonic-gate  * In such cases, AUDIO_ERR_NOEFFECT is returned.
75*7c478bd9Sstevel@tonic-gate  */
76*7c478bd9Sstevel@tonic-gate #define	audio_pause(F)							\
77*7c478bd9Sstevel@tonic-gate 		audio__setpause((F), AUDIO__PLAYREC|AUDIO__PAUSE)
78*7c478bd9Sstevel@tonic-gate #define	audio_pause_play(F)						\
79*7c478bd9Sstevel@tonic-gate 		audio__setpause((F), AUDIO__PLAY|AUDIO__PAUSE)
80*7c478bd9Sstevel@tonic-gate #define	audio_pause_record(F)						\
81*7c478bd9Sstevel@tonic-gate 		audio__setpause((F), AUDIO__RECORD|AUDIO__PAUSE)
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate #define	audio_resume(F)							\
84*7c478bd9Sstevel@tonic-gate 		audio__setpause((F), AUDIO__PLAYREC|AUDIO__RESUME)
85*7c478bd9Sstevel@tonic-gate #define	audio_resume_play(F)						\
86*7c478bd9Sstevel@tonic-gate 		audio__setpause((F), AUDIO__PLAY|AUDIO__RESUME)
87*7c478bd9Sstevel@tonic-gate #define	audio_resume_record(F)						\
88*7c478bd9Sstevel@tonic-gate 		audio__setpause((F), AUDIO__RECORD|AUDIO__RESUME)
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate /*
92*7c478bd9Sstevel@tonic-gate  * The following macros get individual state values.
93*7c478bd9Sstevel@tonic-gate  * 'F' is an open audio file descriptor.
94*7c478bd9Sstevel@tonic-gate  * 'V' is a pointer to an unsigned int.
95*7c478bd9Sstevel@tonic-gate  * The value '*V' is updated after the device state has been read.
96*7c478bd9Sstevel@tonic-gate  */
97*7c478bd9Sstevel@tonic-gate #define	audio_get_play_port(F, V)					\
98*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__PLAY|AUDIO__PORT)
99*7c478bd9Sstevel@tonic-gate #define	audio_get_record_port(F, V)					\
100*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__RECORD|AUDIO__PORT)
101*7c478bd9Sstevel@tonic-gate #define	audio_get_play_balance(F, V)					\
102*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__PLAY|AUDIO__BALANCE)
103*7c478bd9Sstevel@tonic-gate #define	audio_get_record_balance(F, V)					\
104*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__RECORD|AUDIO__BALANCE)
105*7c478bd9Sstevel@tonic-gate #define	audio_get_play_samples(F, V)					\
106*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__PLAY|AUDIO__SAMPLES)
107*7c478bd9Sstevel@tonic-gate #define	audio_get_record_samples(F, V)					\
108*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__RECORD|AUDIO__SAMPLES)
109*7c478bd9Sstevel@tonic-gate #define	audio_get_play_error(F, V)					\
110*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__PLAY|AUDIO__ERROR)
111*7c478bd9Sstevel@tonic-gate #define	audio_get_record_error(F, V)					\
112*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__RECORD|AUDIO__ERROR)
113*7c478bd9Sstevel@tonic-gate #define	audio_get_play_eof(F, V)					\
114*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__PLAY|AUDIO__EOF)
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate #define	audio_get_play_open(F, V)					\
117*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__PLAY|AUDIO__OPEN)
118*7c478bd9Sstevel@tonic-gate #define	audio_get_record_open(F, V)					\
119*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__RECORD|AUDIO__OPEN)
120*7c478bd9Sstevel@tonic-gate #define	audio_get_play_active(F, V)					\
121*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__PLAY|AUDIO__ACTIVE)
122*7c478bd9Sstevel@tonic-gate #define	audio_get_record_active(F, V)					\
123*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__RECORD|AUDIO__ACTIVE)
124*7c478bd9Sstevel@tonic-gate #define	audio_get_play_waiting(F, V)					\
125*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__PLAY|AUDIO__WAITING)
126*7c478bd9Sstevel@tonic-gate #define	audio_get_record_waiting(F, V)					\
127*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__RECORD|AUDIO__WAITING)
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate /*
130*7c478bd9Sstevel@tonic-gate  * The following macros set individual state values.
131*7c478bd9Sstevel@tonic-gate  * 'F' is an open audio file descriptor.
132*7c478bd9Sstevel@tonic-gate  * 'V' is a pointer to an unsigned int.
133*7c478bd9Sstevel@tonic-gate  * The value '*V' is updated after the device state has been read.
134*7c478bd9Sstevel@tonic-gate  */
135*7c478bd9Sstevel@tonic-gate #define	audio_set_play_port(F, V)					\
136*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__PORT)
137*7c478bd9Sstevel@tonic-gate #define	audio_set_record_port(F, V)					\
138*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__PORT)
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate /*
141*7c478bd9Sstevel@tonic-gate  * The value returned for these is the value *before* the state was changed.
142*7c478bd9Sstevel@tonic-gate  * This allows you to atomically read and reset their values.
143*7c478bd9Sstevel@tonic-gate  */
144*7c478bd9Sstevel@tonic-gate #define	audio_set_play_balance(F, V)					\
145*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__BALANCE)
146*7c478bd9Sstevel@tonic-gate #define	audio_set_record_balance(F, V)					\
147*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__BALANCE)
148*7c478bd9Sstevel@tonic-gate #define	audio_set_play_samples(F, V)					\
149*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__SAMPLES)
150*7c478bd9Sstevel@tonic-gate #define	audio_set_record_samples(F, V)					\
151*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__SAMPLES)
152*7c478bd9Sstevel@tonic-gate #define	audio_set_play_error(F, V)					\
153*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__ERROR)
154*7c478bd9Sstevel@tonic-gate #define	audio_set_record_error(F, V)					\
155*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__ERROR)
156*7c478bd9Sstevel@tonic-gate #define	audio_set_play_eof(F, V)					\
157*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__EOF)
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate /* The value can only be set to one.  It is reset to zero on close(). */
160*7c478bd9Sstevel@tonic-gate #define	audio_set_play_waiting(F, V)					\
161*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__WAITING)
162*7c478bd9Sstevel@tonic-gate #define	audio_set_record_waiting(F, V)					\
163*7c478bd9Sstevel@tonic-gate 		audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__WAITING)
164*7c478bd9Sstevel@tonic-gate 
165*7c478bd9Sstevel@tonic-gate /*
166*7c478bd9Sstevel@tonic-gate  * Gain routines take double values, mapping the valid range of gains
167*7c478bd9Sstevel@tonic-gate  * to a floating-point value between zero and one, inclusive.
168*7c478bd9Sstevel@tonic-gate  * The value returned will likely be slightly different than the value set.
169*7c478bd9Sstevel@tonic-gate  * This is because the value is quantized by the device.
170*7c478bd9Sstevel@tonic-gate  *
171*7c478bd9Sstevel@tonic-gate  * Make sure that 'V' is a (double *)!
172*7c478bd9Sstevel@tonic-gate  */
173*7c478bd9Sstevel@tonic-gate #define	audio_get_play_gain(F, V)					\
174*7c478bd9Sstevel@tonic-gate 		audio__setgain((F), (V), AUDIO__PLAY|AUDIO__GAIN)
175*7c478bd9Sstevel@tonic-gate #define	audio_get_record_gain(F, V)					\
176*7c478bd9Sstevel@tonic-gate 		audio__setgain((F), (V), AUDIO__RECORD|AUDIO__GAIN)
177*7c478bd9Sstevel@tonic-gate #define	audio_get_monitor_gain(F, V)					\
178*7c478bd9Sstevel@tonic-gate 		audio__setgain((F), (V), AUDIO__MONGAIN)
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate #define	audio_set_play_gain(F, V)					\
181*7c478bd9Sstevel@tonic-gate 		audio__setgain((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__GAIN)
182*7c478bd9Sstevel@tonic-gate #define	audio_set_record_gain(F, V)					\
183*7c478bd9Sstevel@tonic-gate 		audio__setgain((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__GAIN)
184*7c478bd9Sstevel@tonic-gate #define	audio_set_monitor_gain(F, V)					\
185*7c478bd9Sstevel@tonic-gate 		audio__setgain((F), (V), AUDIO__SET|AUDIO__MONGAIN)
186*7c478bd9Sstevel@tonic-gate 
187*7c478bd9Sstevel@tonic-gate /*
188*7c478bd9Sstevel@tonic-gate  * The following macros flush the audio play and/or record queues.
189*7c478bd9Sstevel@tonic-gate  * Note that requests to flush a channel that is not open will have no effect.
190*7c478bd9Sstevel@tonic-gate  */
191*7c478bd9Sstevel@tonic-gate #define	audio_flush(F)							\
192*7c478bd9Sstevel@tonic-gate 		audio__flush((F), AUDIO__PLAYREC)
193*7c478bd9Sstevel@tonic-gate #define	audio_flush_play(F)						\
194*7c478bd9Sstevel@tonic-gate 		audio__flush((F), AUDIO__PLAY)
195*7c478bd9Sstevel@tonic-gate #define	audio_flush_record(F)						\
196*7c478bd9Sstevel@tonic-gate 		audio__flush((F), AUDIO__RECORD)
197*7c478bd9Sstevel@tonic-gate 
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate /* The following is used for 'which' arguments to get/set info routines */
200*7c478bd9Sstevel@tonic-gate #define	AUDIO__PLAY		(0x10000)
201*7c478bd9Sstevel@tonic-gate #define	AUDIO__RECORD		(0x20000)
202*7c478bd9Sstevel@tonic-gate #define	AUDIO__PLAYREC		(AUDIO__PLAY | AUDIO__RECORD)
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate #define	AUDIO__PORT		(1)
205*7c478bd9Sstevel@tonic-gate #define	AUDIO__SAMPLES		(2)
206*7c478bd9Sstevel@tonic-gate #define	AUDIO__ERROR		(3)
207*7c478bd9Sstevel@tonic-gate #define	AUDIO__EOF		(4)
208*7c478bd9Sstevel@tonic-gate #define	AUDIO__OPEN		(5)
209*7c478bd9Sstevel@tonic-gate #define	AUDIO__ACTIVE		(6)
210*7c478bd9Sstevel@tonic-gate #define	AUDIO__WAITING		(7)
211*7c478bd9Sstevel@tonic-gate #define	AUDIO__GAIN		(8)
212*7c478bd9Sstevel@tonic-gate #define	AUDIO__MONGAIN		(9)
213*7c478bd9Sstevel@tonic-gate #define	AUDIO__PAUSE		(10)
214*7c478bd9Sstevel@tonic-gate #define	AUDIO__RESUME		(11)
215*7c478bd9Sstevel@tonic-gate #define	AUDIO__BALANCE		(12)
216*7c478bd9Sstevel@tonic-gate 
217*7c478bd9Sstevel@tonic-gate #define	AUDIO__SET		(0x80000000)
218*7c478bd9Sstevel@tonic-gate #define	AUDIO__SETVAL_MASK	(0xff)
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
221*7c478bd9Sstevel@tonic-gate }
222*7c478bd9Sstevel@tonic-gate #endif
223*7c478bd9Sstevel@tonic-gate 
224*7c478bd9Sstevel@tonic-gate #endif /* !_MULTIMEDIA_AUDIO_DEVICE_H */
225