blob: e423f2967abaab8cc55a506c2f54ebe11939be7c [file] [log] [blame]
Mikhail Naganov60ced762020-07-23 18:08:26 +00001/*
2 * Copyright (C) 2020 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@7.0;
18
19import android.hardware.audio.common@7.0;
20import IStreamIn;
21import IStreamOut;
22
23interface IDevice {
24 /**
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 *
Mikhail Naganov3f1457b2020-12-17 15:01:54 -0800106 * Note: INVALID_ARGUMENTS is returned both in the case when the
107 * HAL can not use the provided config and in the case when
108 * the value of any argument is invalid. In the latter case the
109 * HAL must provide a default initialized suggested config.
110 *
Mikhail Naganov60ced762020-07-23 18:08:26 +0000111 * @param ioHandle handle assigned by AudioFlinger.
112 * @param device device type and (if needed) address.
113 * @param config stream configuration.
114 * @param flags additional flags.
115 * @param sourceMetadata Description of the audio that will be played.
116 May be used by implementations to configure hardware effects.
117 * @return retval operation completion status.
118 * @return outStream created output stream.
Mikhail Naganov3f1457b2020-12-17 15:01:54 -0800119 * @return suggestedConfig in the case of rejection of the proposed config,
120 * a config suggested by the HAL.
Mikhail Naganov60ced762020-07-23 18:08:26 +0000121 */
122 openOutputStream(
123 AudioIoHandle ioHandle,
124 DeviceAddress device,
125 AudioConfig config,
Mikhail Naganov355dd062020-09-24 18:00:44 +0000126 vec<AudioInOutFlag> flags,
Mikhail Naganov60ced762020-07-23 18:08:26 +0000127 SourceMetadata sourceMetadata) generates (
128 Result retval,
129 IStreamOut outStream,
130 AudioConfig suggestedConfig);
131
132 /**
133 * This method creates and opens the audio hardware input stream.
134 * If the stream can not be opened with the proposed audio config,
135 * HAL must provide suggested values for the audio config.
136 *
Mikhail Naganov3f1457b2020-12-17 15:01:54 -0800137 * Note: INVALID_ARGUMENTS is returned both in the case when the
138 * HAL can not use the provided config and in the case when
139 * the value of any argument is invalid. In the latter case the
140 * HAL must provide a default initialized suggested config.
141 *
Mikhail Naganov60ced762020-07-23 18:08:26 +0000142 * @param ioHandle handle assigned by AudioFlinger.
143 * @param device device type and (if needed) address.
144 * @param config stream configuration.
145 * @param flags additional flags.
146 * @param sinkMetadata Description of the audio that is suggested by the client.
147 * May be used by implementations to configure processing effects.
148 * @return retval operation completion status.
149 * @return inStream in case of success, created input stream.
Mikhail Naganov3f1457b2020-12-17 15:01:54 -0800150 * @return suggestedConfig in the case of rejection of the proposed config,
151 * a config suggested by the HAL.
Mikhail Naganov60ced762020-07-23 18:08:26 +0000152 */
153 openInputStream(
154 AudioIoHandle ioHandle,
155 DeviceAddress device,
156 AudioConfig config,
Mikhail Naganov355dd062020-09-24 18:00:44 +0000157 vec<AudioInOutFlag> flags,
Mikhail Naganov60ced762020-07-23 18:08:26 +0000158 SinkMetadata sinkMetadata) generates (
159 Result retval,
160 IStreamIn inStream,
161 AudioConfig suggestedConfig);
162
163 /**
164 * Returns whether HAL supports audio patches. Patch represents a connection
165 * between signal source(s) and signal sink(s). If HAL doesn't support
166 * patches natively (in hardware) then audio system will need to establish
167 * them in software.
168 *
169 * @return supports true if audio patches are supported.
170 */
171 supportsAudioPatches() generates (bool supports);
172
173 /**
174 * Creates an audio patch between several source and sink ports. The handle
175 * is allocated by the HAL and must be unique for this audio HAL module.
176 *
Mikhail Naganov4ffb0922021-01-11 17:59:10 -0800177 * Optional method. HAL must support it if 'supportsAudioPatches' returns
178 * 'true'.
179 *
Mikhail Naganov60ced762020-07-23 18:08:26 +0000180 * @param sources patch sources.
181 * @param sinks patch sinks.
182 * @return retval operation completion status.
183 * @return patch created patch handle.
184 */
185 createAudioPatch(vec<AudioPortConfig> sources, vec<AudioPortConfig> sinks)
186 generates (Result retval, AudioPatchHandle patch);
187
188 /**
189 * Updates an audio patch.
190 *
191 * Use of this function is preferred to releasing and re-creating a patch
192 * as the HAL module can figure out a way of switching the route without
193 * causing audio disruption.
194 *
Mikhail Naganov4ffb0922021-01-11 17:59:10 -0800195 * Optional method. HAL must support it if 'supportsAudioPatches' returns
196 * 'true'.
197 *
Mikhail Naganov60ced762020-07-23 18:08:26 +0000198 * @param previousPatch handle of the previous patch to update.
199 * @param sources new patch sources.
200 * @param sinks new patch sinks.
201 * @return retval operation completion status.
202 * @return patch updated patch handle.
203 */
204 updateAudioPatch(
205 AudioPatchHandle previousPatch,
206 vec<AudioPortConfig> sources,
207 vec<AudioPortConfig> sinks) generates (
208 Result retval, AudioPatchHandle patch);
209
210 /**
211 * Release an audio patch.
212 *
Mikhail Naganov4ffb0922021-01-11 17:59:10 -0800213 * Optional method. HAL must support it if 'supportsAudioPatches' returns
214 * 'true'.
215 *
Mikhail Naganov60ced762020-07-23 18:08:26 +0000216 * @param patch patch handle.
217 * @return retval operation completion status.
218 */
219 releaseAudioPatch(AudioPatchHandle patch) generates (Result retval);
220
221 /**
222 * Returns the list of supported attributes for a given audio port.
223 *
224 * As input, 'port' contains the information (type, role, address etc...)
225 * needed by the HAL to identify the port.
226 *
227 * As output, 'resultPort' contains possible attributes (sampling rates,
228 * formats, channel masks, gain controllers...) for this port.
229 *
230 * @param port port identifier.
231 * @return retval operation completion status.
232 * @return resultPort port descriptor with all parameters filled up.
233 */
234 getAudioPort(AudioPort port)
235 generates (Result retval, AudioPort resultPort);
236
237 /**
238 * Set audio port configuration.
239 *
240 * @param config audio port configuration.
241 * @return retval operation completion status.
242 */
243 setAudioPortConfig(AudioPortConfig config) generates (Result retval);
244
245 /**
246 * Gets the HW synchronization source of the device. Calling this method is
247 * equivalent to getting AUDIO_PARAMETER_HW_AV_SYNC on the legacy HAL.
248 * Optional method
249 *
250 * @return retval operation completion status: OK or NOT_SUPPORTED.
251 * @return hwAvSync HW synchronization source
252 */
253 getHwAvSync() generates (Result retval, AudioHwSync hwAvSync);
254
255 /**
256 * Sets whether the screen is on. Calling this method is equivalent to
257 * setting AUDIO_PARAMETER_KEY_SCREEN_STATE on the legacy HAL.
258 * Optional method
259 *
260 * @param turnedOn whether the screen is turned on.
261 * @return retval operation completion status.
262 */
263 setScreenState(bool turnedOn) generates (Result retval);
264
265 /**
266 * Generic method for retrieving vendor-specific parameter values.
267 * The framework does not interpret the parameters, they are passed
268 * in an opaque manner between a vendor application and HAL.
269 *
270 * Multiple parameters can be retrieved at the same time.
271 * The implementation should return as many requested parameters
272 * as possible, even if one or more is not supported
273 *
274 * @param context provides more information about the request
275 * @param keys keys of the requested parameters
276 * @return retval operation completion status.
277 * OK must be returned if keys is empty.
278 * NOT_SUPPORTED must be returned if at least one key is unknown.
279 * @return parameters parameter key value pairs.
280 * Must contain the value of all requested keys if retval == OK
281 */
282 getParameters(vec<ParameterValue> context, vec<string> keys)
283 generates (Result retval, vec<ParameterValue> parameters);
284
285 /**
286 * Generic method for setting vendor-specific parameter values.
287 * The framework does not interpret the parameters, they are passed
288 * in an opaque manner between a vendor application and HAL.
289 *
290 * Multiple parameters can be set at the same time though this is
291 * discouraged as it make failure analysis harder.
292 *
293 * If possible, a failed setParameters should not impact the platform state.
294 *
295 * @param context provides more information about the request
296 * @param parameters parameter key value pairs.
297 * @return retval operation completion status.
298 * All parameters must be successfully set for OK to be returned
299 */
300 setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
301 generates (Result retval);
302
303 /**
304 * Returns an array with available microphones in device.
305 *
306 * @return retval NOT_SUPPORTED if there are no microphones on this device
307 * INVALID_STATE if the call is not successful,
308 * OK otherwise.
309 *
310 * @return microphones array with microphones info
311 */
312 getMicrophones()
313 generates(Result retval, vec<MicrophoneInfo> microphones);
314
315 /**
316 * Notifies the device module about the connection state of an input/output
317 * device attached to it. Calling this method is equivalent to setting
318 * AUDIO_PARAMETER_DEVICE_[DIS]CONNECT on the legacy HAL.
319 *
320 * @param address audio device specification.
321 * @param connected whether the device is connected.
322 * @return retval operation completion status.
323 */
324 setConnectedState(DeviceAddress address, bool connected)
325 generates (Result retval);
326
327 /**
328 * Called by the framework to deinitialize the device and free up
329 * all currently allocated resources. It is recommended to close
330 * the device on the client side as soon as it is becomes unused.
331 *
332 * Note that all streams must be closed by the client before
333 * attempting to close the device they belong to.
334 *
335 * @return retval OK in case the success.
336 * INVALID_STATE if the device was already closed
337 * or there are streams currently opened.
338 */
Mikhail Naganov60ced762020-07-23 18:08:26 +0000339 close() generates (Result retval);
340
341 /**
342 * Applies an audio effect to an audio device. The effect is inserted
343 * according to its insertion preference specified by INSERT_... EffectFlags
344 * in the EffectDescriptor.
345 *
346 * @param device identifies the sink or source device this effect must be applied to.
347 * "device" is the AudioPortHandle indicated for the device when the audio
348 * patch connecting that device was created.
349 * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
350 * the effect to add.
351 * @return retval operation completion status.
352 */
353 addDeviceEffect(AudioPortHandle device, uint64_t effectId) generates (Result retval);
354
355 /**
356 * Stops applying an audio effect to an audio device.
357 *
358 * @param device identifies the sink or source device this effect was applied to.
359 * "device" is the AudioPortHandle indicated for the device when the audio
360 * patch is created at the audio HAL.
361 * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
362 * the effect.
363 * @return retval operation completion status.
364 */
365 removeDeviceEffect(AudioPortHandle device, uint64_t effectId) generates (Result retval);
366};