1 /* 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 17 #ifndef ANDROID_HARDWARE_AUDIO_PRIMARYDEVICE_H 18 #define ANDROID_HARDWARE_AUDIO_PRIMARYDEVICE_H 19 20 #include PATH(android/hardware/audio/FILE_VERSION/IPrimaryDevice.h) 21 22 #include "Device.h" 23 24 #include <hidl/Status.h> 25 26 #include <hidl/MQDescriptor.h> 27 28 namespace android { 29 namespace hardware { 30 namespace audio { 31 namespace CPP_VERSION { 32 namespace implementation { 33 34 using ::android::sp; 35 using ::android::hardware::hidl_string; 36 using ::android::hardware::hidl_vec; 37 using ::android::hardware::Return; 38 using ::android::hardware::Void; 39 using namespace ::android::hardware::audio::common::CPP_VERSION; 40 using namespace ::android::hardware::audio::CPP_VERSION; 41 42 struct PrimaryDevice : public IPrimaryDevice { 43 explicit PrimaryDevice(audio_hw_device_t* device); 44 45 // Methods from ::android::hardware::audio::CPP_VERSION::IDevice follow. 46 Return<Result> initCheck() override; 47 Return<Result> setMasterVolume(float volume) override; 48 Return<void> getMasterVolume(getMasterVolume_cb _hidl_cb) override; 49 Return<Result> setMicMute(bool mute) override; 50 Return<void> getMicMute(getMicMute_cb _hidl_cb) override; 51 Return<Result> setMasterMute(bool mute) override; 52 Return<void> getMasterMute(getMasterMute_cb _hidl_cb) override; 53 Return<void> getInputBufferSize(const AudioConfig& config, 54 getInputBufferSize_cb _hidl_cb) override; 55 56 Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device, 57 const AudioConfig& config, 58 #if MAJOR_VERSION <= 6 59 AudioOutputFlags flags, 60 #else 61 const AudioOutputFlags& flags, 62 #endif 63 #if MAJOR_VERSION >= 4 64 const SourceMetadata& sourceMetadata, 65 #endif 66 openOutputStream_cb _hidl_cb) override; 67 Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device, 68 const AudioConfig& config, 69 #if MAJOR_VERSION <= 6 70 AudioInputFlags flags, 71 #else 72 const AudioInputFlags& flags, 73 #endif 74 #if MAJOR_VERSION == 2 75 AudioSource source, 76 #elif MAJOR_VERSION >= 4 77 const SinkMetadata& sinkMetadata, 78 #endif 79 openInputStream_cb _hidl_cb) override; 80 81 Return<bool> supportsAudioPatches() override; 82 Return<void> createAudioPatch(const hidl_vec<AudioPortConfig>& sources, 83 const hidl_vec<AudioPortConfig>& sinks, 84 createAudioPatch_cb _hidl_cb) override; 85 Return<Result> releaseAudioPatch(int32_t patch) override; 86 Return<void> getAudioPort(const AudioPort& port, getAudioPort_cb _hidl_cb) override; 87 Return<Result> setAudioPortConfig(const AudioPortConfig& config) override; 88 89 Return<Result> setScreenState(bool turnedOn) override; 90 91 #if MAJOR_VERSION == 2 92 Return<AudioHwSync> getHwAvSync() override; 93 Return<void> getParameters(const hidl_vec<hidl_string>& keys, 94 getParameters_cb _hidl_cb) override; 95 Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override; 96 Return<void> debugDump(const hidl_handle& fd) override; 97 #elif MAJOR_VERSION >= 4 98 Return<void> getHwAvSync(getHwAvSync_cb _hidl_cb) override; 99 Return<void> getParameters(const hidl_vec<ParameterValue>& context, 100 const hidl_vec<hidl_string>& keys, 101 getParameters_cb _hidl_cb) override; 102 Return<Result> setParameters(const hidl_vec<ParameterValue>& context, 103 const hidl_vec<ParameterValue>& parameters) override; 104 Return<void> getMicrophones(getMicrophones_cb _hidl_cb) override; 105 Return<Result> setConnectedState(const DeviceAddress& address, bool connected) override; 106 #endif 107 #if MAJOR_VERSION >= 6 108 Return<Result> close() override; 109 Return<Result> addDeviceEffect(AudioPortHandle device, uint64_t effectId) override; 110 Return<Result> removeDeviceEffect(AudioPortHandle device, uint64_t effectId) override; 111 Return<void> updateAudioPatch(int32_t previousPatch, const hidl_vec<AudioPortConfig>& sources, 112 const hidl_vec<AudioPortConfig>& sinks, 113 updateAudioPatch_cb _hidl_cb) override; 114 #endif 115 116 Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; 117 118 // Methods from ::android::hardware::audio::CPP_VERSION::IPrimaryDevice follow. 119 Return<Result> setVoiceVolume(float volume) override; 120 Return<Result> setMode(AudioMode mode) override; 121 Return<void> getBtScoNrecEnabled(getBtScoNrecEnabled_cb _hidl_cb) override; 122 Return<Result> setBtScoNrecEnabled(bool enabled) override; 123 Return<void> getBtScoWidebandEnabled(getBtScoWidebandEnabled_cb _hidl_cb) override; 124 Return<Result> setBtScoWidebandEnabled(bool enabled) override; 125 Return<void> getTtyMode(getTtyMode_cb _hidl_cb) override; 126 Return<Result> setTtyMode(IPrimaryDevice::TtyMode mode) override; 127 Return<void> getHacEnabled(getHacEnabled_cb _hidl_cb) override; 128 Return<Result> setHacEnabled(bool enabled) override; 129 130 #if MAJOR_VERSION >= 4 131 Return<Result> setBtScoHeadsetDebugName(const hidl_string& name) override; 132 Return<void> getBtHfpEnabled(getBtHfpEnabled_cb _hidl_cb) override; 133 Return<Result> setBtHfpEnabled(bool enabled) override; 134 Return<Result> setBtHfpSampleRate(uint32_t sampleRateHz) override; 135 Return<Result> setBtHfpVolume(float volume) override; 136 Return<Result> updateRotation(IPrimaryDevice::Rotation rotation) override; 137 #endif 138 139 private: 140 sp<Device> mDevice; 141 142 virtual ~PrimaryDevice(); 143 }; 144 145 } // namespace implementation 146 } // namespace CPP_VERSION 147 } // namespace audio 148 } // namespace hardware 149 } // namespace android 150 151 #endif // ANDROID_HARDWARE_AUDIO_PRIMARYDEVICE_H 152