Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [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 HIDL_GENERATED_android_hardware_audio_V2_0_Device_H_ |
| 18 | #define HIDL_GENERATED_android_hardware_audio_V2_0_Device_H_ |
| 19 | |
| 20 | #include <memory> |
| 21 | |
| 22 | #include <media/AudioParameter.h> |
| 23 | #include <hardware/audio.h> |
| 24 | |
| 25 | #include <android/hardware/audio/2.0/IDevice.h> |
| 26 | #include <hidl/Status.h> |
| 27 | |
| 28 | #include <hidl/MQDescriptor.h> |
| 29 | |
| 30 | #include "ParametersUtil.h" |
| 31 | |
| 32 | namespace android { |
| 33 | namespace hardware { |
| 34 | namespace audio { |
| 35 | namespace V2_0 { |
| 36 | namespace implementation { |
| 37 | |
| 38 | using ::android::hardware::audio::common::V2_0::AudioConfig; |
| 39 | using ::android::hardware::audio::common::V2_0::AudioGain; |
| 40 | using ::android::hardware::audio::common::V2_0::AudioGainConfig; |
| 41 | using ::android::hardware::audio::common::V2_0::AudioGainMode; |
| 42 | using ::android::hardware::audio::common::V2_0::AudioHwSync; |
| 43 | using ::android::hardware::audio::common::V2_0::AudioInputFlag; |
| 44 | using ::android::hardware::audio::common::V2_0::AudioMixLatencyClass; |
| 45 | using ::android::hardware::audio::common::V2_0::AudioOffloadInfo; |
| 46 | using ::android::hardware::audio::common::V2_0::AudioOutputFlag; |
| 47 | using ::android::hardware::audio::common::V2_0::AudioPatchHandle; |
| 48 | using ::android::hardware::audio::common::V2_0::AudioPort; |
| 49 | using ::android::hardware::audio::common::V2_0::AudioPortConfig; |
| 50 | using ::android::hardware::audio::common::V2_0::AudioPortConfigMask; |
| 51 | using ::android::hardware::audio::common::V2_0::AudioPortRole; |
| 52 | using ::android::hardware::audio::common::V2_0::AudioPortType; |
| 53 | using ::android::hardware::audio::common::V2_0::AudioSource; |
| 54 | using ::android::hardware::audio::common::V2_0::AudioStreamType; |
| 55 | using ::android::hardware::audio::V2_0::DeviceAddress; |
| 56 | using ::android::hardware::audio::V2_0::IDevice; |
| 57 | using ::android::hardware::audio::V2_0::IStreamIn; |
| 58 | using ::android::hardware::audio::V2_0::IStreamOut; |
| 59 | using ::android::hardware::audio::V2_0::ParameterValue; |
| 60 | using ::android::hardware::audio::V2_0::Result; |
| 61 | using ::android::hardware::Return; |
| 62 | using ::android::hardware::Void; |
| 63 | using ::android::hardware::hidl_vec; |
| 64 | using ::android::hardware::hidl_string; |
| 65 | using ::android::sp; |
| 66 | |
| 67 | struct Device : public IDevice, public ParametersUtil { |
| 68 | explicit Device(audio_hw_device_t* device); |
| 69 | |
| 70 | // Methods from ::android::hardware::audio::V2_0::IDevice follow. |
| 71 | Return<Result> initCheck() override; |
| 72 | Return<Result> setMasterVolume(float volume) override; |
| 73 | Return<void> getMasterVolume(getMasterVolume_cb _hidl_cb) override; |
| 74 | Return<Result> setMicMute(bool mute) override; |
| 75 | Return<void> getMicMute(getMicMute_cb _hidl_cb) override; |
| 76 | Return<Result> setMasterMute(bool mute) override; |
| 77 | Return<void> getMasterMute(getMasterMute_cb _hidl_cb) override; |
| 78 | Return<void> getInputBufferSize( |
| 79 | const AudioConfig& config, getInputBufferSize_cb _hidl_cb) override; |
| 80 | Return<void> openOutputStream( |
| 81 | int32_t ioHandle, |
| 82 | const DeviceAddress& device, |
| 83 | const AudioConfig& config, |
| 84 | AudioOutputFlag flags, |
| 85 | openOutputStream_cb _hidl_cb) override; |
| 86 | Return<void> openInputStream( |
| 87 | int32_t ioHandle, |
| 88 | const DeviceAddress& device, |
| 89 | const AudioConfig& config, |
| 90 | AudioInputFlag flags, |
| 91 | AudioSource source, |
| 92 | openInputStream_cb _hidl_cb) override; |
| 93 | Return<void> createAudioPatch( |
| 94 | const hidl_vec<AudioPortConfig>& sources, |
| 95 | const hidl_vec<AudioPortConfig>& sinks, |
| 96 | createAudioPatch_cb _hidl_cb) override; |
| 97 | Return<Result> releaseAudioPatch(int32_t patch) override; |
| 98 | Return<void> getAudioPort(const AudioPort& port, getAudioPort_cb _hidl_cb) override; |
| 99 | Return<Result> setAudioPortConfig(const AudioPortConfig& config) override; |
| 100 | Return<AudioHwSync> getHwAvSync() override; |
| 101 | Return<Result> setScreenState(bool turnedOn) override; |
| 102 | Return<void> getParameters( |
| 103 | const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override; |
| 104 | Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override; |
Martijn Coenen | 70b9a15 | 2016-11-18 15:29:32 +0100 | [diff] [blame] | 105 | Return<void> debugDump(const hidl_handle& fd) override; |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 106 | |
| 107 | // Utility methods for extending interfaces. |
| 108 | Result analyzeStatus(const char* funcName, int status); |
| 109 | audio_hw_device_t* device() const { return mDevice; } |
| 110 | |
| 111 | private: |
| 112 | audio_hw_device_t *mDevice; |
| 113 | |
| 114 | static void audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig); |
| 115 | static void audioGainConfigFromHal( |
| 116 | const struct audio_gain_config& halConfig, AudioGainConfig* config); |
| 117 | static void audioGainConfigToHal( |
| 118 | const AudioGainConfig& config, struct audio_gain_config* halConfig); |
| 119 | static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain); |
| 120 | static void audioGainToHal(const AudioGain& gain, struct audio_gain* halGain); |
| 121 | static void audioOffloadInfoToHal( |
| 122 | const AudioOffloadInfo& offload, audio_offload_info_t* halOffload); |
| 123 | static void audioPortConfigFromHal( |
| 124 | const struct audio_port_config& halConfig, AudioPortConfig* config); |
| 125 | static void audioPortConfigToHal( |
| 126 | const AudioPortConfig& config, struct audio_port_config* halConfig); |
| 127 | static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal( |
| 128 | const hidl_vec<AudioPortConfig>& configs); |
| 129 | static void audioPortFromHal(const struct audio_port& halPort, AudioPort* port); |
| 130 | static void audioPortToHal(const AudioPort& port, struct audio_port* halPort); |
| 131 | |
| 132 | virtual ~Device(); |
| 133 | |
| 134 | // Methods from ParametersUtil. |
| 135 | char* halGetParameters(const char* keys) override; |
| 136 | int halSetParameters(const char* keysAndValues) override; |
| 137 | |
| 138 | uint32_t version() const { return mDevice->common.version; } |
| 139 | }; |
| 140 | |
| 141 | } // namespace implementation |
| 142 | } // namespace V2_0 |
| 143 | } // namespace audio |
| 144 | } // namespace hardware |
| 145 | } // namespace android |
| 146 | |
| 147 | #endif // HIDL_GENERATED_android_hardware_audio_V2_0_Device_H_ |