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