blob: 591e56509894c408b259aaad8a6447e9aea43bdd [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 {
24 typedef android.hardware.audio@4.0::Result Result;
25
26 /**
27 * Returns whether the audio hardware interface has been initialized.
28 *
29 * @return retval OK on success, NOT_INITIALIZED on failure.
30 */
31 initCheck() generates (Result retval);
32
33 /**
34 * Sets the audio volume for all audio activities other than voice call. If
35 * NOT_SUPPORTED is returned, the software mixer will emulate this
36 * capability.
37 *
38 * @param volume 1.0f means unity, 0.0f is zero.
39 * @return retval operation completion status.
40 */
41 setMasterVolume(float volume) generates (Result retval);
42
43 /**
44 * Get the current master volume value for the HAL, if the HAL supports
45 * master volume control. For example, AudioFlinger will query this value
46 * from the primary audio HAL when the service starts and use the value for
47 * setting the initial master volume across all HALs. HALs which do not
48 * support this method must return NOT_SUPPORTED in 'retval'.
49 *
50 * @return retval operation completion status.
51 * @return volume 1.0f means unity, 0.0f is zero.
52 */
53 getMasterVolume() generates (Result retval, float volume);
54
55 /**
56 * Sets microphone muting state.
57 *
58 * @param mute whether microphone is muted.
59 * @return retval operation completion status.
60 */
61 setMicMute(bool mute) generates (Result retval);
62
63 /**
64 * Gets whether microphone is muted.
65 *
66 * @return retval operation completion status.
67 * @return mute whether microphone is muted.
68 */
69 getMicMute() generates (Result retval, bool mute);
70
71 /**
72 * Set the audio mute status for all audio activities. If the return value
73 * is NOT_SUPPORTED, the software mixer will emulate this capability.
74 *
75 * @param mute whether audio is muted.
76 * @return retval operation completion status.
77 */
78 setMasterMute(bool mute) generates (Result retval);
79
80 /**
81 * Get the current master mute status for the HAL, if the HAL supports
82 * master mute control. AudioFlinger will query this value from the primary
83 * audio HAL when the service starts and use the value for setting the
84 * initial master mute across all HALs. HAL must indicate that the feature
85 * is not supported by returning NOT_SUPPORTED status.
86 *
87 * @return retval operation completion status.
88 * @return mute whether audio is muted.
89 */
90 getMasterMute() generates (Result retval, bool mute);
91
92 /**
93 * Returns audio input buffer size according to parameters passed or
94 * INVALID_ARGUMENTS if one of the parameters is not supported.
95 *
96 * @param config audio configuration.
97 * @return retval operation completion status.
98 * @return bufferSize input buffer size in bytes.
99 */
100 getInputBufferSize(AudioConfig config)
101 generates (Result retval, uint64_t bufferSize);
102
103 /**
104 * This method creates and opens the audio hardware output stream.
105 * If the stream can not be opened with the proposed audio config,
106 * HAL must provide suggested values for the audio config.
107 *
108 * @param ioHandle handle assigned by AudioFlinger.
109 * @param device device type and (if needed) address.
110 * @param config stream configuration.
111 * @param flags additional flags.
Kevin Rocard14dbb1e2018-01-24 19:12:06 -0800112 * @param sourceMetadata Description of the audio that will be played.
113 May be used by implementations to configure hardware effects.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800114 * @return retval operation completion status.
115 * @return outStream created output stream.
116 * @return suggestedConfig in case of invalid parameters, suggested config.
117 */
118 openOutputStream(
119 AudioIoHandle ioHandle,
120 DeviceAddress device,
121 AudioConfig config,
Kevin Rocard14dbb1e2018-01-24 19:12:06 -0800122 bitfield<AudioOutputFlag> flags,
123 SourceMetadata sourceMetadata) generates (
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800124 Result retval,
125 IStreamOut outStream,
126 AudioConfig suggestedConfig);
127
128 /**
129 * This method creates and opens the audio hardware input stream.
130 * If the stream can not be opened with the proposed audio config,
131 * HAL must provide suggested values for the audio config.
132 *
133 * @param ioHandle handle assigned by AudioFlinger.
134 * @param device device type and (if needed) address.
135 * @param config stream configuration.
136 * @param flags additional flags.
137 * @param source source specification.
Kevin Rocard14dbb1e2018-01-24 19:12:06 -0800138 * @param sinkMetadata Description of the audio that is suggested by the client.
139 * May be used by implementations to configure hardware effects.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800140 * @return retval operation completion status.
141 * @return inStream in case of success, created input stream.
142 * @return suggestedConfig in case of invalid parameters, suggested config.
143 */
144 openInputStream(
145 AudioIoHandle ioHandle,
146 DeviceAddress device,
147 AudioConfig config,
Kevin Rocard79c57402018-01-24 10:02:30 -0800148 bitfield<AudioInputFlag> flags,
Kevin Rocard14dbb1e2018-01-24 19:12:06 -0800149 SinkMetadata sinkMetadata) generates (
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800150 Result retval,
151 IStreamIn inStream,
152 AudioConfig suggestedConfig);
153
154 /**
155 * Returns whether HAL supports audio patches.
156 *
157 * @return supports true if audio patches are supported.
158 */
159 supportsAudioPatches() generates (bool supports);
160
161 /**
162 * Creates an audio patch between several source and sink ports. The handle
163 * is allocated by the HAL and must be unique for this audio HAL module.
164 *
165 * @param sources patch sources.
166 * @param sinks patch sinks.
167 * @return retval operation completion status.
168 * @return patch created patch handle.
169 */
170 createAudioPatch(vec<AudioPortConfig> sources, vec<AudioPortConfig> sinks)
171 generates (Result retval, AudioPatchHandle patch);
172
173 /**
174 * Release an audio patch.
175 *
176 * @param patch patch handle.
177 * @return retval operation completion status.
178 */
179 releaseAudioPatch(AudioPatchHandle patch) generates (Result retval);
180
181 /**
182 * Returns the list of supported attributes for a given audio port.
183 *
184 * As input, 'port' contains the information (type, role, address etc...)
185 * needed by the HAL to identify the port.
186 *
187 * As output, 'resultPort' contains possible attributes (sampling rates,
188 * formats, channel masks, gain controllers...) for this port.
189 *
190 * @param port port identifier.
191 * @return retval operation completion status.
192 * @return resultPort port descriptor with all parameters filled up.
193 */
194 getAudioPort(AudioPort port)
195 generates (Result retval, AudioPort resultPort);
196
197 /**
198 * Set audio port configuration.
199 *
200 * @param config audio port configuration.
201 * @return retval operation completion status.
202 */
203 setAudioPortConfig(AudioPortConfig config) generates (Result retval);
204
205 /**
206 * Gets the HW synchronization source of the device. Calling this method is
207 * equivalent to getting AUDIO_PARAMETER_HW_AV_SYNC on the legacy HAL.
Kevin Rocard74980b52018-01-20 22:12:57 -0800208 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800209 *
Kevin Rocard74980b52018-01-20 22:12:57 -0800210 * @return retval operation completion status: OK or NOT_SUPPORTED.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800211 * @return hwAvSync HW synchronization source
212 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800213 getHwAvSync() generates (Result retval, AudioHwSync hwAvSync);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800214
215 /**
216 * Sets whether the screen is on. Calling this method is equivalent to
217 * setting AUDIO_PARAMETER_KEY_SCREEN_STATE on the legacy HAL.
Kevin Rocard74980b52018-01-20 22:12:57 -0800218 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800219 *
220 * @param turnedOn whether the screen is turned on.
221 * @return retval operation completion status.
222 */
223 setScreenState(bool turnedOn) generates (Result retval);
224
225 /**
226 * Generic method for retrieving vendor-specific parameter values.
227 * The framework does not interpret the parameters, they are passed
228 * in an opaque manner between a vendor application and HAL.
229 *
Kevin Rocard74980b52018-01-20 22:12:57 -0800230 * Multiple parameters can be retrieved at the same time.
231 * The implementation should return as many requested parameters
232 * as possible, even if one or more is not supported
233 *
234 * @param context provides more information about the request
235 * @param keys keys of the requested parameters
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800236 * @return retval operation completion status.
Kevin Rocard74980b52018-01-20 22:12:57 -0800237 * OK must be returned if keys is empty.
238 * NOT_SUPPORTED must be returned if at least one key is unknown.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800239 * @return parameters parameter key value pairs.
Kevin Rocard74980b52018-01-20 22:12:57 -0800240 * Must contain the value of all requested keys if retval == OK
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800241 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800242 getParameters(vec<ParameterValue> context, vec<string> keys)
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800243 generates (Result retval, vec<ParameterValue> parameters);
244
245 /**
246 * Generic method for setting vendor-specific parameter values.
247 * The framework does not interpret the parameters, they are passed
248 * in an opaque manner between a vendor application and HAL.
249 *
Kevin Rocard74980b52018-01-20 22:12:57 -0800250 * Multiple parameters can be set at the same time though this is
251 * discouraged as it make failure analysis harder.
252 *
253 * If possible, a failed setParameters should not impact the platform state.
254 *
255 * @param context provides more information about the request
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800256 * @param parameters parameter key value pairs.
257 * @return retval operation completion status.
Kevin Rocard74980b52018-01-20 22:12:57 -0800258 * All parameters must be successfully set for OK to be returned
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800259 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800260 setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
261 generates (Result retval);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800262};