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