blob: a281b1ddcdfca4abd5d9b6d4238a781f6e539b29 [file] [log] [blame]
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -07001/*
Kevin Rocard96d2cd92018-11-14 16:22:07 -08002 * Copyright (C) 2018 The Android Open Source Project
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -07003 *
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
Kevin Rocard96d2cd92018-11-14 16:22:07 -080017#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_AUTOMATICGAINCONTROLEFFECT_H
18#define ANDROID_HARDWARE_AUDIO_EFFECT_AUTOMATICGAINCONTROLEFFECT_H
19
20#include PATH(android/hardware/audio/effect/FILE_VERSION/IAutomaticGainControlEffect.h)
21
22#include "Effect.h"
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070023
24#include <system/audio_effects/effect_agc.h>
25
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070026#include <hidl/Status.h>
27
28#include <hidl/MQDescriptor.h>
29
Kevin Rocard30a7fcc2018-03-01 15:08:07 -080030#include "VersionUtils.h"
31
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070032namespace android {
33namespace hardware {
34namespace audio {
35namespace effect {
Kevin Rocard96d2cd92018-11-14 16:22:07 -080036namespace CPP_VERSION {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070037namespace implementation {
38
Kevin Rocard55b10612018-11-12 12:33:16 -080039using ::android::sp;
40using ::android::hardware::hidl_string;
41using ::android::hardware::hidl_vec;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070042using ::android::hardware::Return;
43using ::android::hardware::Void;
Kevin Rocard96d2cd92018-11-14 16:22:07 -080044using ::android::hardware::audio::effect::CPP_VERSION::IAutomaticGainControlEffect;
45using ::android::hardware::audio::effect::CPP_VERSION::Result;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070046
47struct AutomaticGainControlEffect : public IAutomaticGainControlEffect {
48 explicit AutomaticGainControlEffect(effect_handle_t handle);
49
Kevin Rocard96d2cd92018-11-14 16:22:07 -080050 // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
Kevin Rocard22505e62017-12-14 18:50:12 -080051 Return<Result> init() override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070052 Return<Result> setConfig(
Kevin Rocard22505e62017-12-14 18:50:12 -080053 const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
54 const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
55 Return<Result> reset() override;
56 Return<Result> enable() override;
57 Return<Result> disable() override;
Kevin Rocard30a7fcc2018-03-01 15:08:07 -080058 Return<Result> setDevice(AudioDeviceBitfield device) override;
Kevin Rocard22505e62017-12-14 18:50:12 -080059 Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
60 setAndGetVolume_cb _hidl_cb) override;
61 Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
62 Return<Result> setAudioMode(AudioMode mode) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070063 Return<Result> setConfigReverse(
Kevin Rocard22505e62017-12-14 18:50:12 -080064 const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
65 const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Kevin Rocard30a7fcc2018-03-01 15:08:07 -080066 Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Kevin Rocard22505e62017-12-14 18:50:12 -080067 Return<void> getConfig(getConfig_cb _hidl_cb) override;
68 Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070069 Return<void> getSupportedAuxChannelsConfigs(
Kevin Rocard22505e62017-12-14 18:50:12 -080070 uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
71 Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
72 Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
73 Return<Result> setAudioSource(AudioSource source) override;
74 Return<Result> offload(const EffectOffloadParameter& param) override;
75 Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
76 Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
77 Return<Result> setProcessBuffers(const AudioBuffer& inBuffer,
78 const AudioBuffer& outBuffer) override;
79 Return<void> command(uint32_t commandId, const hidl_vec<uint8_t>& data, uint32_t resultMaxSize,
80 command_cb _hidl_cb) override;
81 Return<Result> setParameter(const hidl_vec<uint8_t>& parameter,
82 const hidl_vec<uint8_t>& value) override;
83 Return<void> getParameter(const hidl_vec<uint8_t>& parameter, uint32_t valueMaxSize,
84 getParameter_cb _hidl_cb) override;
85 Return<void> getSupportedConfigsForFeature(uint32_t featureId, uint32_t maxConfigs,
86 uint32_t configSize,
87 getSupportedConfigsForFeature_cb _hidl_cb) override;
88 Return<void> getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize,
89 getCurrentConfigForFeature_cb _hidl_cb) override;
90 Return<Result> setCurrentConfigForFeature(uint32_t featureId,
91 const hidl_vec<uint8_t>& configData) override;
92 Return<Result> close() override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070093
Kevin Rocard62588b62017-12-20 11:07:12 -080094 // Methods from
Kevin Rocard96d2cd92018-11-14 16:22:07 -080095 // ::android::hardware::audio::effect::CPP_VERSION::IAutomaticGainControlEffect follow.
Kevin Rocard22505e62017-12-14 18:50:12 -080096 Return<Result> setTargetLevel(int16_t targetLevelMb) override;
97 Return<void> getTargetLevel(getTargetLevel_cb _hidl_cb) override;
98 Return<Result> setCompGain(int16_t compGainMb) override;
99 Return<void> getCompGain(getCompGain_cb _hidl_cb) override;
100 Return<Result> setLimiterEnabled(bool enabled) override;
101 Return<void> isLimiterEnabled(isLimiterEnabled_cb _hidl_cb) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700102 Return<Result> setAllProperties(
Kevin Rocard22505e62017-12-14 18:50:12 -0800103 const IAutomaticGainControlEffect::AllProperties& properties) override;
104 Return<void> getAllProperties(getAllProperties_cb _hidl_cb) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700105
Kevin Rocard22505e62017-12-14 18:50:12 -0800106 private:
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700107 sp<Effect> mEffect;
108
109 virtual ~AutomaticGainControlEffect();
110
Kevin Rocard22505e62017-12-14 18:50:12 -0800111 void propertiesFromHal(const t_agc_settings& halProperties,
112 IAutomaticGainControlEffect::AllProperties* properties);
113 void propertiesToHal(const IAutomaticGainControlEffect::AllProperties& properties,
114 t_agc_settings* halProperties);
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700115};
116
117} // namespace implementation
Kevin Rocard96d2cd92018-11-14 16:22:07 -0800118} // namespace CPP_VERSION
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700119} // namespace effect
120} // namespace audio
121} // namespace hardware
122} // namespace android
Kevin Rocard96d2cd92018-11-14 16:22:07 -0800123
124#endif // ANDROID_HARDWARE_AUDIO_EFFECT_AUTOMATICGAINCONTROLEFFECT_H