diff options
author | Chase Wu <chasewu@google.com> | 2022-05-18 02:47:30 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-05-18 02:47:30 +0000 |
commit | 23db4ae8b902ed99bde4cfa91c691a911e16db7a (patch) | |
tree | 3332b82d1b1f942a5700ee1c43bd2c944174e5ce | |
parent | cb29b25ff197d3789ee3157be239f8ee8969694b (diff) | |
parent | dee07ba9427325d84d2ff7f3c7f5eaa32e3ef931 (diff) | |
download | pixel-23db4ae8b902ed99bde4cfa91c691a911e16db7a.tar.gz |
Merge "vibrator: cs40l25: add chirp switch support" into tm-dev
-rw-r--r-- | vibrator/cs40l25/Hardware.h | 9 | ||||
-rw-r--r-- | vibrator/cs40l25/Vibrator.cpp | 7 | ||||
-rw-r--r-- | vibrator/cs40l25/Vibrator.h | 3 | ||||
-rw-r--r-- | vibrator/cs40l25/tests/mocks.h | 1 |
4 files changed, 18 insertions, 2 deletions
diff --git a/vibrator/cs40l25/Hardware.h b/vibrator/cs40l25/Hardware.h index f74fe931..9fa3685f 100644 --- a/vibrator/cs40l25/Hardware.h +++ b/vibrator/cs40l25/Hardware.h @@ -74,7 +74,9 @@ class HwApi : public Vibrator::HwApi, private HwApiBase { bool setGpioRiseScale(uint32_t value) override { return set(value, &mGpioRiseScale); } bool pollVibeState(bool value) override { return poll(value, &mVibeState); } bool setClabEnable(bool value) override { return set(value, &mClabEnable); } - bool getAvailablePwleSegments(uint32_t *value) override { return get(value, &mAvailablePwleSegments); } + bool getAvailablePwleSegments(uint32_t *value) override { + return get(value, &mAvailablePwleSegments); + } bool hasPwle() override { return has(mPwle); } bool setPwle(std::string value) override { return set(value, &mPwle); } bool setPwleRampDown(uint32_t value) override { return set(value, &mPwleRampDown); } @@ -185,6 +187,11 @@ class HwCal : public Vibrator::HwCal, private HwCalBase { *value = V_LONG_DEFAULT; return true; } + bool isChirpEnabled() override { + bool value; + getProperty("chirp.enabled", &value, false); + return value; + } void debug(int fd) override { HwCalBase::debug(fd); } }; diff --git a/vibrator/cs40l25/Vibrator.cpp b/vibrator/cs40l25/Vibrator.cpp index 1c1a53c9..3da42340 100644 --- a/vibrator/cs40l25/Vibrator.cpp +++ b/vibrator/cs40l25/Vibrator.cpp @@ -273,6 +273,7 @@ Vibrator::Vibrator(std::unique_ptr<HwApi> hwapi, std::unique_ptr<HwCal> hwcal) createPwleMaxLevelLimitMap(); mIsUnderExternalControl = false; setPwleRampDown(); + mIsChirpEnabled = mHwCal->isChirpEnabled(); } ndk::ScopedAStatus Vibrator::getCapabilities(int32_t *_aidl_return) { @@ -286,7 +287,7 @@ ndk::ScopedAStatus Vibrator::getCapabilities(int32_t *_aidl_return) { if (mHwApi->hasAspEnable() || hasHapticAlsaDevice()) { ret |= IVibrator::CAP_EXTERNAL_CONTROL; } - if (mHwApi->hasPwle()) { + if (mHwApi->hasPwle() && mIsChirpEnabled) { ret |= IVibrator::CAP_FREQUENCY_CONTROL | IVibrator::CAP_COMPOSE_PWLE_EFFECTS; } *_aidl_return = ret; @@ -705,6 +706,10 @@ ndk::ScopedAStatus Vibrator::composePwle(const std::vector<PrimitivePwle> &compo std::ostringstream pwleBuilder; std::string pwleQueue; + if (!mIsChirpEnabled) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); + } + if (composite.size() <= 0 || composite.size() > mCompositionSizeMax) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } diff --git a/vibrator/cs40l25/Vibrator.h b/vibrator/cs40l25/Vibrator.h index 1395aa94..ad229a40 100644 --- a/vibrator/cs40l25/Vibrator.h +++ b/vibrator/cs40l25/Vibrator.h @@ -133,6 +133,8 @@ class Vibrator : public BnVibrator { virtual bool getTickVolLevels(std::array<uint32_t, 2> *value) = 0; virtual bool getClickVolLevels(std::array<uint32_t, 2> *value) = 0; virtual bool getLongVolLevels(std::array<uint32_t, 2> *value) = 0; + // Checks if the chirp feature is enabled. + virtual bool isChirpEnabled() = 0; // Emit diagnostic information to the given file. virtual void debug(int fd) = 0; }; @@ -221,6 +223,7 @@ class Vibrator : public BnVibrator { bool mIsUnderExternalControl; float mResonantFrequency; int8_t mActiveId{-1}; + bool mIsChirpEnabled; }; } // namespace vibrator diff --git a/vibrator/cs40l25/tests/mocks.h b/vibrator/cs40l25/tests/mocks.h index 8f2c672e..0edb8a63 100644 --- a/vibrator/cs40l25/tests/mocks.h +++ b/vibrator/cs40l25/tests/mocks.h @@ -67,6 +67,7 @@ class MockCal : public ::aidl::android::hardware::vibrator::Vibrator::HwCal { MOCK_METHOD1(getTickVolLevels, bool(std::array<uint32_t, 2> *value)); MOCK_METHOD1(getClickVolLevels, bool(std::array<uint32_t, 2> *value)); MOCK_METHOD1(getLongVolLevels, bool(std::array<uint32_t, 2> *value)); + MOCK_METHOD0(isChirpEnabled, bool()); MOCK_METHOD1(debug, void(int fd)); ~MockCal() override { destructor(); }; |