blob: bb585688d9b99e529bca7769c229e2a9da62bfe4 [file] [log] [blame]
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -08001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.audio@4.0;
18
19import android.hardware.audio.common@4.0;
20import IStreamIn;
21import IStreamOut;
22
23interface IDevice {
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -080024 /**
25 * Returns whether the audio hardware interface has been initialized.
26 *
27 * @return retval OK on success, NOT_INITIALIZED on failure.
28 */
29 initCheck() generates (Result retval);
30
31 /**
32 * Sets the audio volume for all audio activities other than voice call. If
33 * NOT_SUPPORTED is returned, the software mixer will emulate this
34 * capability.
35 *
36 * @param volume 1.0f means unity, 0.0f is zero.
37 * @return retval operation completion status.
38 */
39 setMasterVolume(float volume) generates (Result retval);
40
41 /**
42 * Get the current master volume value for the HAL, if the HAL supports
43 * master volume control. For example, AudioFlinger will query this value
44 * from the primary audio HAL when the service starts and use the value for
45 * setting the initial master volume across all HALs. HALs which do not
46 * support this method must return NOT_SUPPORTED in 'retval'.
47 *
48 * @return retval operation completion status.
49 * @return volume 1.0f means unity, 0.0f is zero.
50 */
51 getMasterVolume() generates (Result retval, float volume);
52
53 /**
54 * Sets microphone muting state.
55 *
56 * @param mute whether microphone is muted.
57 * @return retval operation completion status.
58 */
59 setMicMute(bool mute) generates (Result retval);
60
61 /**
62 * Gets whether microphone is muted.
63 *
64 * @return retval operation completion status.
65 * @return mute whether microphone is muted.
66 */
67 getMicMute() generates (Result retval, bool mute);
68
69 /**
70 * Set the audio mute status for all audio activities. If the return value
71 * is NOT_SUPPORTED, the software mixer will emulate this capability.
72 *
73 * @param mute whether audio is muted.
74 * @return retval operation completion status.
75 */
76 setMasterMute(bool mute) generates (Result retval);
77
78 /**
79 * Get the current master mute status for the HAL, if the HAL supports
80 * master mute control. AudioFlinger will query this value from the primary
81 * audio HAL when the service starts and use the value for setting the
82 * initial master mute across all HALs. HAL must indicate that the feature
83 * is not supported by returning NOT_SUPPORTED status.
84 *
85 * @return retval operation completion status.
86 * @return mute whether audio is muted.
87 */
88 getMasterMute() generates (Result retval, bool mute);
89
90 /**
91 * Returns audio input buffer size according to parameters passed or
92 * INVALID_ARGUMENTS if one of the parameters is not supported.
93 *
94 * @param config audio configuration.
95 * @return retval operation completion status.
96 * @return bufferSize input buffer size in bytes.
97 */
98 getInputBufferSize(AudioConfig config)
99 generates (Result retval, uint64_t bufferSize);
100
101 /**
102 * This method creates and opens the audio hardware output stream.
103 * If the stream can not be opened with the proposed audio config,
104 * HAL must provide suggested values for the audio config.
105 *
106 * @param ioHandle handle assigned by AudioFlinger.
107 * @param device device type and (if needed) address.
108 * @param config stream configuration.
109 * @param flags additional flags.
Kevin Rocard14dbb1e2018-01-24 19:12:06 -0800110 * @param sourceMetadata Description of the audio that will be played.
111 May be used by implementations to configure hardware effects.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800112 * @return retval operation completion status.
113 * @return outStream created output stream.
114 * @return suggestedConfig in case of invalid parameters, suggested config.
115 */
116 openOutputStream(
117 AudioIoHandle ioHandle,
118 DeviceAddress device,
119 AudioConfig config,
Kevin Rocard14dbb1e2018-01-24 19:12:06 -0800120 bitfield<AudioOutputFlag> flags,
121 SourceMetadata sourceMetadata) generates (
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800122 Result retval,
123 IStreamOut outStream,
124 AudioConfig suggestedConfig);
125
126 /**
127 * This method creates and opens the audio hardware input stream.
128 * If the stream can not be opened with the proposed audio config,
129 * HAL must provide suggested values for the audio config.
130 *
131 * @param ioHandle handle assigned by AudioFlinger.
132 * @param device device type and (if needed) address.
133 * @param config stream configuration.
134 * @param flags additional flags.
135 * @param source source specification.
Kevin Rocard14dbb1e2018-01-24 19:12:06 -0800136 * @param sinkMetadata Description of the audio that is suggested by the client.
137 * May be used by implementations to configure hardware effects.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800138 * @return retval operation completion status.
139 * @return inStream in case of success, created input stream.
140 * @return suggestedConfig in case of invalid parameters, suggested config.
141 */
142 openInputStream(
143 AudioIoHandle ioHandle,
144 DeviceAddress device,
145 AudioConfig config,
Kevin Rocard79c57402018-01-24 10:02:30 -0800146 bitfield<AudioInputFlag> flags,
Kevin Rocard14dbb1e2018-01-24 19:12:06 -0800147 SinkMetadata sinkMetadata) generates (
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800148 Result retval,
149 IStreamIn inStream,
150 AudioConfig suggestedConfig);
151
152 /**
153 * Returns whether HAL supports audio patches.
154 *
155 * @return supports true if audio patches are supported.
156 */
157 supportsAudioPatches() generates (bool supports);
158
159 /**
160 * Creates an audio patch between several source and sink ports. The handle
161 * is allocated by the HAL and must be unique for this audio HAL module.
162 *
163 * @param sources patch sources.
164 * @param sinks patch sinks.
165 * @return retval operation completion status.
166 * @return patch created patch handle.
167 */
168 createAudioPatch(vec<AudioPortConfig> sources, vec<AudioPortConfig> sinks)
169 generates (Result retval, AudioPatchHandle patch);
170
171 /**
172 * Release an audio patch.
173 *
174 * @param patch patch handle.
175 * @return retval operation completion status.
176 */
177 releaseAudioPatch(AudioPatchHandle patch) generates (Result retval);
178
179 /**
180 * Returns the list of supported attributes for a given audio port.
181 *
182 * As input, 'port' contains the information (type, role, address etc...)
183 * needed by the HAL to identify the port.
184 *
185 * As output, 'resultPort' contains possible attributes (sampling rates,
186 * formats, channel masks, gain controllers...) for this port.
187 *
188 * @param port port identifier.
189 * @return retval operation completion status.
190 * @return resultPort port descriptor with all parameters filled up.
191 */
192 getAudioPort(AudioPort port)
193 generates (Result retval, AudioPort resultPort);
194
195 /**
196 * Set audio port configuration.
197 *
198 * @param config audio port configuration.
199 * @return retval operation completion status.
200 */
201 setAudioPortConfig(AudioPortConfig config) generates (Result retval);
202
203 /**
204 * Gets the HW synchronization source of the device. Calling this method is
205 * equivalent to getting AUDIO_PARAMETER_HW_AV_SYNC on the legacy HAL.
Kevin Rocard74980b52018-01-20 22:12:57 -0800206 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800207 *
Kevin Rocard74980b52018-01-20 22:12:57 -0800208 * @return retval operation completion status: OK or NOT_SUPPORTED.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800209 * @return hwAvSync HW synchronization source
210 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800211 getHwAvSync() generates (Result retval, AudioHwSync hwAvSync);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800212
213 /**
214 * Sets whether the screen is on. Calling this method is equivalent to
215 * setting AUDIO_PARAMETER_KEY_SCREEN_STATE on the legacy HAL.
Kevin Rocard74980b52018-01-20 22:12:57 -0800216 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800217 *
218 * @param turnedOn whether the screen is turned on.
219 * @return retval operation completion status.
220 */
221 setScreenState(bool turnedOn) generates (Result retval);
222
223 /**
224 * Generic method for retrieving vendor-specific parameter values.
225 * The framework does not interpret the parameters, they are passed
226 * in an opaque manner between a vendor application and HAL.
227 *
Kevin Rocard74980b52018-01-20 22:12:57 -0800228 * Multiple parameters can be retrieved at the same time.
229 * The implementation should return as many requested parameters
230 * as possible, even if one or more is not supported
231 *
232 * @param context provides more information about the request
233 * @param keys keys of the requested parameters
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800234 * @return retval operation completion status.
Kevin Rocard74980b52018-01-20 22:12:57 -0800235 * OK must be returned if keys is empty.
236 * NOT_SUPPORTED must be returned if at least one key is unknown.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800237 * @return parameters parameter key value pairs.
Kevin Rocard74980b52018-01-20 22:12:57 -0800238 * Must contain the value of all requested keys if retval == OK
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800239 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800240 getParameters(vec<ParameterValue> context, vec<string> keys)
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800241 generates (Result retval, vec<ParameterValue> parameters);
242
243 /**
244 * Generic method for setting vendor-specific parameter values.
245 * The framework does not interpret the parameters, they are passed
246 * in an opaque manner between a vendor application and HAL.
247 *
Kevin Rocard74980b52018-01-20 22:12:57 -0800248 * Multiple parameters can be set at the same time though this is
249 * discouraged as it make failure analysis harder.
250 *
251 * If possible, a failed setParameters should not impact the platform state.
252 *
253 * @param context provides more information about the request
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800254 * @param parameters parameter key value pairs.
255 * @return retval operation completion status.
Kevin Rocard74980b52018-01-20 22:12:57 -0800256 * All parameters must be successfully set for OK to be returned
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800257 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800258 setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
259 generates (Result retval);
Ricardo Garcia520e53d2018-01-31 09:37:44 -0800260
261 /**
262 * Returns an array with available microphones in device.
263 *
264 * @return retval INVALID_STATE if the call is not successful,
265 * OK otherwise.
266 *
267 * @return microphones array with microphones info
268 */
269 getMicrophones()
270 generates(Result retval, vec<MicrophoneInfo> microphones);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800271};