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 PATH(android/hardware/audio/FILE_VERSION/IDevice.h) 21 #include PATH(android/hardware/audio/FILE_VERSION/IPrimaryDevice.h) 22 #include <media/audiohal/DeviceHalInterface.h> 23 24 #include "ConversionHelperHidl.h" 25 26 using ::android::hardware::audio::CPP_VERSION::IDevice; 27 using ::android::hardware::audio::CPP_VERSION::IPrimaryDevice; 28 using ::android::hardware::Return; 29 30 namespace android { 31 namespace CPP_VERSION { 32 33 class 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 audio_devices_t outputDevice, 90 const char *outputDeviceAddress, 91 sp<StreamInHalInterface> *inStream); 92 93 // Returns whether createAudioPatch and releaseAudioPatch operations are supported. 94 virtual status_t supportsAudioPatches(bool *supportsPatches); 95 96 // Creates an audio patch between several source and sink ports. 97 virtual status_t createAudioPatch( 98 unsigned int num_sources, 99 const struct audio_port_config *sources, 100 unsigned int num_sinks, 101 const struct audio_port_config *sinks, 102 audio_patch_handle_t *patch); 103 104 // Releases an audio patch. 105 virtual status_t releaseAudioPatch(audio_patch_handle_t patch); 106 107 // Fills the list of supported attributes for a given audio port. 108 virtual status_t getAudioPort(struct audio_port *port); 109 110 // Set audio port configuration. 111 virtual status_t setAudioPortConfig(const struct audio_port_config *config); 112 113 // List microphones 114 virtual status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones); 115 116 status_t addDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override; 117 status_t removeDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override; 118 119 virtual status_t dump(int fd); 120 121 private: 122 friend class DevicesFactoryHalHidl; 123 sp<IDevice> mDevice; 124 sp<IPrimaryDevice> mPrimaryDevice; // Null if it's not a primary device. 125 126 // Can not be constructed directly by clients. 127 explicit DeviceHalHidl(const sp<IDevice>& device); 128 129 // The destructor automatically closes the device. 130 virtual ~DeviceHalHidl(); 131 }; 132 133 } // namespace CPP_VERSION 134 } // namespace android 135 136 #endif // ANDROID_HARDWARE_DEVICE_HAL_HIDL_H 137