summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTai Kuo <taikuo@google.com>2021-12-22 22:54:59 +0800
committerTai Kuo <taikuo@google.com>2021-12-22 22:59:58 +0800
commit273097e5d6a42f03ab06e2af292bf6bcfaf698dd (patch)
tree7fa7f90f567be5d0c293063088476d055b6d7e73
parentc1b306452fe8a65ff9f22d13af83caa196f808dc (diff)
downloadpixel-273097e5d6a42f03ab06e2af292bf6bcfaf698dd.tar.gz
vibrator: cs40l26: property-controlled primitives support
Bug: 208766820 Test: adb shell getprop | grep vibrator Test: adb shell idlcli vibrator getSupportedPrimitives Test: adb shell idlcli vibrator getCapabilities Test: adb shell dumpsys vibrator_manager Test: adb shell dumpsys android.hardware.vibrator.IVibrator/default Signed-off-by: Tai Kuo <taikuo@google.com> Change-Id: I2d0aec88aa2d4d339a635a6c8e92273861a374d2
-rw-r--r--vibrator/cs40l26/Hardware.h3
-rw-r--r--vibrator/cs40l26/Vibrator.cpp27
-rw-r--r--vibrator/cs40l26/Vibrator.h3
3 files changed, 26 insertions, 7 deletions
diff --git a/vibrator/cs40l26/Hardware.h b/vibrator/cs40l26/Hardware.h
index 2a194875..a555874e 100644
--- a/vibrator/cs40l26/Hardware.h
+++ b/vibrator/cs40l26/Hardware.h
@@ -123,6 +123,9 @@ class HwCal : public Vibrator::HwCal, private HwCalBase {
getProperty("chirp.enabled", &value, false);
return value;
}
+ bool getSupportedPrimitives(uint32_t *value) override {
+ return getProperty("supported_primitives", value, (uint32_t)0);
+ }
void debug(int fd) override { HwCalBase::debug(fd); }
};
diff --git a/vibrator/cs40l26/Vibrator.cpp b/vibrator/cs40l26/Vibrator.cpp
index c7dca9da..9f08c882 100644
--- a/vibrator/cs40l26/Vibrator.cpp
+++ b/vibrator/cs40l26/Vibrator.cpp
@@ -345,6 +345,25 @@ Vibrator::Vibrator(std::unique_ptr<HwApi> hwapi, std::unique_ptr<HwCal> hwcal)
mIsUnderExternalControl = false;
mIsChirpEnabled = mHwCal->isChirpEnabled();
+
+ uint32_t capabilities;
+ mHwCal->getSupportedPrimitives(&capabilities);
+ std::vector<CompositePrimitive> defaultSupported = {
+ CompositePrimitive::NOOP, CompositePrimitive::CLICK,
+ CompositePrimitive::THUD, CompositePrimitive::SPIN,
+ CompositePrimitive::QUICK_RISE, CompositePrimitive::SLOW_RISE,
+ CompositePrimitive::QUICK_FALL, CompositePrimitive::LIGHT_TICK,
+ CompositePrimitive::LOW_TICK,
+ };
+ if (capabilities > 0) {
+ for (auto e : defaultSupported) {
+ if (capabilities & (1 << uint32_t(e))) {
+ mSupportedPrimitives.emplace_back(e);
+ }
+ }
+ } else {
+ mSupportedPrimitives = defaultSupported;
+ }
}
ndk::ScopedAStatus Vibrator::getCapabilities(int32_t *_aidl_return) {
@@ -462,13 +481,7 @@ ndk::ScopedAStatus Vibrator::getCompositionSizeMax(int32_t *maxSize) {
}
ndk::ScopedAStatus Vibrator::getSupportedPrimitives(std::vector<CompositePrimitive> *supported) {
- *supported = {
- CompositePrimitive::NOOP, CompositePrimitive::CLICK,
- CompositePrimitive::THUD, CompositePrimitive::SPIN,
- CompositePrimitive::QUICK_RISE, CompositePrimitive::SLOW_RISE,
- CompositePrimitive::QUICK_FALL, CompositePrimitive::LIGHT_TICK,
- CompositePrimitive::LOW_TICK,
- };
+ *supported = mSupportedPrimitives;
return ndk::ScopedAStatus::ok();
}
diff --git a/vibrator/cs40l26/Vibrator.h b/vibrator/cs40l26/Vibrator.h
index c18fe593..78265e93 100644
--- a/vibrator/cs40l26/Vibrator.h
+++ b/vibrator/cs40l26/Vibrator.h
@@ -90,6 +90,8 @@ class Vibrator : public BnVibrator {
virtual bool getLongVolLevels(std::array<uint32_t, 2> *value) = 0;
// Checks if the chirp feature is enabled.
virtual bool isChirpEnabled() = 0;
+ // Obtains the supported primitive effects.
+ virtual bool getSupportedPrimitives(uint32_t *value) = 0;
// Emit diagnostic information to the given file.
virtual void debug(int fd) = 0;
};
@@ -178,6 +180,7 @@ class Vibrator : public BnVibrator {
bool mIsUnderExternalControl;
float mLongEffectScale = 1.0;
bool mIsChirpEnabled;
+ std::vector<CompositePrimitive> mSupportedPrimitives;
};
} // namespace vibrator