blob: d6b0ab081830042dec071c71b46b0aba33e9d27f [file] [log] [blame]
Mikhail Naganovf558e022016-11-14 17:45:17 -08001/*
2 * Copyright (C) 2016 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
17#ifndef ANDROID_HARDWARE_DEVICE_HAL_HIDL_H
18#define ANDROID_HARDWARE_DEVICE_HAL_HIDL_H
19
20#include <android/hardware/audio/2.0/IDevice.h>
Mikhail Naganov9063fa72017-06-30 15:33:51 -070021#include <android/hardware/audio/2.0/IPrimaryDevice.h>
Mikhail Naganovf558e022016-11-14 17:45:17 -080022#include <media/audiohal/DeviceHalInterface.h>
23
24#include "ConversionHelperHidl.h"
25
26using ::android::hardware::audio::V2_0::IDevice;
Mikhail Naganov9063fa72017-06-30 15:33:51 -070027using ::android::hardware::audio::V2_0::IPrimaryDevice;
Mikhail Naganovf558e022016-11-14 17:45:17 -080028using ::android::hardware::Return;
29
30namespace android {
Kevin Rocarddf9b4202018-05-10 19:56:08 -070031namespace V2_0 {
Mikhail Naganovf558e022016-11-14 17:45:17 -080032
33class DeviceHalHidl : public DeviceHalInterface, public ConversionHelperHidl
34{
35 public:
36 // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
37 virtual status_t getSupportedDevices(uint32_t *devices);
38
39 // Check to see if the audio hardware interface has been initialized.
40 virtual status_t initCheck();
41
42 // Set the audio volume of a voice call. Range is between 0.0 and 1.0.
43 virtual status_t setVoiceVolume(float volume);
44
45 // Set the audio volume for all audio activities other than voice call.
46 virtual status_t setMasterVolume(float volume);
47
48 // Get the current master volume value for the HAL.
49 virtual status_t getMasterVolume(float *volume);
50
51 // Called when the audio mode changes.
52 virtual status_t setMode(audio_mode_t mode);
53
54 // Muting control.
55 virtual status_t setMicMute(bool state);
56 virtual status_t getMicMute(bool *state);
57 virtual status_t setMasterMute(bool state);
58 virtual status_t getMasterMute(bool *state);
59
60 // Set global audio parameters.
61 virtual status_t setParameters(const String8& kvPairs);
62
63 // Get global audio parameters.
64 virtual status_t getParameters(const String8& keys, String8 *values);
65
66 // Returns audio input buffer size according to parameters passed.
67 virtual status_t getInputBufferSize(const struct audio_config *config,
68 size_t *size);
69
70 // Creates and opens the audio hardware output stream. The stream is closed
71 // by releasing all references to the returned object.
72 virtual status_t openOutputStream(
73 audio_io_handle_t handle,
74 audio_devices_t devices,
75 audio_output_flags_t flags,
76 struct audio_config *config,
77 const char *address,
78 sp<StreamOutHalInterface> *outStream);
79
80 // Creates and opens the audio hardware input stream. The stream is closed
81 // by releasing all references to the returned object.
82 virtual status_t openInputStream(
83 audio_io_handle_t handle,
84 audio_devices_t devices,
85 struct audio_config *config,
86 audio_input_flags_t flags,
87 const char *address,
88 audio_source_t source,
89 sp<StreamInHalInterface> *inStream);
90
91 // Returns whether createAudioPatch and releaseAudioPatch operations are supported.
92 virtual status_t supportsAudioPatches(bool *supportsPatches);
93
94 // Creates an audio patch between several source and sink ports.
95 virtual status_t createAudioPatch(
96 unsigned int num_sources,
97 const struct audio_port_config *sources,
98 unsigned int num_sinks,
99 const struct audio_port_config *sinks,
100 audio_patch_handle_t *patch);
101
102 // Releases an audio patch.
103 virtual status_t releaseAudioPatch(audio_patch_handle_t patch);
104
105 // Fills the list of supported attributes for a given audio port.
106 virtual status_t getAudioPort(struct audio_port *port);
107
108 // Set audio port configuration.
109 virtual status_t setAudioPortConfig(const struct audio_port_config *config);
110
jiabin9ff780e2018-03-19 18:19:52 -0700111 // List microphones
112 virtual status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones);
113
Mikhail Naganovf558e022016-11-14 17:45:17 -0800114 virtual status_t dump(int fd);
115
116 private:
117 friend class DevicesFactoryHalHidl;
118 sp<IDevice> mDevice;
Mikhail Naganov9063fa72017-06-30 15:33:51 -0700119 sp<IPrimaryDevice> mPrimaryDevice; // Null if it's not a primary device.
Mikhail Naganovf558e022016-11-14 17:45:17 -0800120
121 // Can not be constructed directly by clients.
122 explicit DeviceHalHidl(const sp<IDevice>& device);
123
124 // The destructor automatically closes the device.
125 virtual ~DeviceHalHidl();
126};
127
Kevin Rocarddf9b4202018-05-10 19:56:08 -0700128} // namespace V2_0
Mikhail Naganovf558e022016-11-14 17:45:17 -0800129} // namespace android
130
131#endif // ANDROID_HARDWARE_DEVICE_HAL_HIDL_H