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, AudioOutputFlagBitfield flags, 58 #if MAJOR_VERSION >= 4 59 const SourceMetadata& sourceMetadata, 60 #endif 61 openOutputStream_cb _hidl_cb) override; 62 63 Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device, 64 const AudioConfig& config, AudioInputFlagBitfield flags, 65 AudioSource source, openInputStream_cb _hidl_cb); 66 #if MAJOR_VERSION >= 4 67 Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device, 68 const AudioConfig& config, AudioInputFlagBitfield flags, 69 const SinkMetadata& sinkMetadata, 70 openInputStream_cb _hidl_cb) override; 71 #endif 72 73 Return<bool> supportsAudioPatches() override; 74 Return<void> createAudioPatch(const hidl_vec<AudioPortConfig>& sources, 75 const hidl_vec<AudioPortConfig>& sinks, 76 createAudioPatch_cb _hidl_cb) override; 77 Return<Result> releaseAudioPatch(int32_t patch) override; 78 Return<void> getAudioPort(const AudioPort& port, getAudioPort_cb _hidl_cb) override; 79 Return<Result> setAudioPortConfig(const AudioPortConfig& config) override; 80 81 Return<Result> setScreenState(bool turnedOn) override; 82 83 #if MAJOR_VERSION == 2 84 Return<AudioHwSync> getHwAvSync() override; 85 Return<void> getParameters(const hidl_vec<hidl_string>& keys, 86 getParameters_cb _hidl_cb) override; 87 Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override; 88 Return<void> debugDump(const hidl_handle& fd) override; 89 #elif MAJOR_VERSION >= 4 90 Return<void> getHwAvSync(getHwAvSync_cb _hidl_cb) override; 91 Return<void> getParameters(const hidl_vec<ParameterValue>& context, 92 const hidl_vec<hidl_string>& keys, 93 getParameters_cb _hidl_cb) override; 94 Return<Result> setParameters(const hidl_vec<ParameterValue>& context, 95 const hidl_vec<ParameterValue>& parameters) override; 96 Return<void> getMicrophones(getMicrophones_cb _hidl_cb) override; 97 Return<Result> setConnectedState(const DeviceAddress& address, bool connected) override; 98 #endif 99 100 Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; 101 102 // Methods from ::android::hardware::audio::CPP_VERSION::IPrimaryDevice follow. 103 Return<Result> setVoiceVolume(float volume) override; 104 Return<Result> setMode(AudioMode mode) override; 105 Return<void> getBtScoNrecEnabled(getBtScoNrecEnabled_cb _hidl_cb) override; 106 Return<Result> setBtScoNrecEnabled(bool enabled) override; 107 Return<void> getBtScoWidebandEnabled(getBtScoWidebandEnabled_cb _hidl_cb) override; 108 Return<Result> setBtScoWidebandEnabled(bool enabled) override; 109 Return<void> getTtyMode(getTtyMode_cb _hidl_cb) override; 110 Return<Result> setTtyMode(IPrimaryDevice::TtyMode mode) override; 111 Return<void> getHacEnabled(getHacEnabled_cb _hidl_cb) override; 112 Return<Result> setHacEnabled(bool enabled) override; 113 114 #if MAJOR_VERSION >= 4 115 Return<Result> setBtScoHeadsetDebugName(const hidl_string& name) override; 116 Return<void> getBtHfpEnabled(getBtHfpEnabled_cb _hidl_cb) override; 117 Return<Result> setBtHfpEnabled(bool enabled) override; 118 Return<Result> setBtHfpSampleRate(uint32_t sampleRateHz) override; 119 Return<Result> setBtHfpVolume(float volume) override; 120 Return<Result> updateRotation(IPrimaryDevice::Rotation rotation) override; 121 #endif 122 123 private: 124 sp<Device> mDevice; 125 126 virtual ~PrimaryDevice(); 127 }; 128 129 } // namespace implementation 130 } // namespace CPP_VERSION 131 } // namespace audio 132 } // namespace hardware 133 } // namespace android 134 135 #endif // ANDROID_HARDWARE_AUDIO_PRIMARYDEVICE_H 136