summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2022-12-26 01:34:28 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-12-26 01:34:28 +0000
commit9782050d3470275abe39c3cffec59843dea850be (patch)
tree198ed5201acd9f4e1eecdf1d6bb914fc574b1854
parentdacdb1fb86d7c99abe125184646f04a05b4a7ff4 (diff)
parentdd6edd23ae9632916329b8f43754d130a71c9bb3 (diff)
downloadpixel-9782050d3470275abe39c3cffec59843dea850be.tar.gz
Merge changes from topic "L26_performance_improvement" into tm-qpr-dev
* changes: cs40l26: Prevent waveform number out of range cs40l26: Improve the performance for primitive effects
-rw-r--r--vibrator/cs40l26/Hardware.h7
-rw-r--r--vibrator/cs40l26/Vibrator.cpp11
-rw-r--r--vibrator/cs40l26/Vibrator.h3
3 files changed, 19 insertions, 2 deletions
diff --git a/vibrator/cs40l26/Hardware.h b/vibrator/cs40l26/Hardware.h
index ae052baa..2143b96b 100644
--- a/vibrator/cs40l26/Hardware.h
+++ b/vibrator/cs40l26/Hardware.h
@@ -220,7 +220,10 @@ class HwApi : public Vibrator::HwApi, private HwApiBase {
ALOGE("Invalid waveform index for OWT erase: %d", effectIndex);
return false;
}
-
+ // Turn off the waiting time for SVC init phase to complete since chip
+ // should already under STOP state
+ setMinOnOffInterval(0);
+ // Do erase flow
if (effectIndex < WAVEFORM_MAX_INDEX) {
/* Normal situation. Only erase the effect which we just played. */
if (ioctl(fd, EVIOCRMFF, effectIndex) < 0) {
@@ -248,6 +251,8 @@ class HwApi : public Vibrator::HwApi, private HwApiBase {
(*effect)[i].id = -1;
}
}
+ // Turn on the waiting time for SVC init phase to complete
+ setMinOnOffInterval(Vibrator::MIN_ON_OFF_INTERVAL_US);
return true;
}
diff --git a/vibrator/cs40l26/Vibrator.cpp b/vibrator/cs40l26/Vibrator.cpp
index 3af057c7..25012243 100644
--- a/vibrator/cs40l26/Vibrator.cpp
+++ b/vibrator/cs40l26/Vibrator.cpp
@@ -48,7 +48,6 @@ static constexpr uint32_t WAVEFORM_LONG_VIBRATION_THRESHOLD_MS = 50;
static constexpr uint8_t VOLTAGE_SCALE_MAX = 100;
static constexpr int8_t MAX_COLD_START_LATENCY_MS = 6; // I2C Transaction + DSP Return-From-Standby
-static constexpr uint32_t MIN_ON_OFF_INTERVAL_US = 8500; // SVC initialization time
static constexpr int8_t MAX_PAUSE_TIMING_ERROR_MS = 1; // ALERT Irq Handling
static constexpr uint32_t MAX_TIME_MS = UINT16_MAX;
@@ -1277,10 +1276,20 @@ void Vibrator::waitForComplete(std::shared_ptr<IVibratorCallback> &&callback) {
mHwApi->pollVibeState(VIBE_STATE_STOPPED);
const std::scoped_lock<std::mutex> lock(mActiveId_mutex);
+ uint32_t effectCount = WAVEFORM_MAX_PHYSICAL_INDEX;
if ((mActiveId >= WAVEFORM_MAX_PHYSICAL_INDEX) &&
(!mHwApi->eraseOwtEffect(mInputFd, mActiveId, &mFfEffects))) {
ALOGE("Failed to clean up the composed effect %d", mActiveId);
+ } else {
+ ALOGD("waitForComplete: Vibrator is already off");
+ }
+ mHwApi->getEffectCount(&effectCount);
+ // Do waveform number checking
+ if ((effectCount > WAVEFORM_MAX_PHYSICAL_INDEX) &&
+ (!mHwApi->eraseOwtEffect(mInputFd, WAVEFORM_MAX_INDEX, &mFfEffects))) {
+ ALOGE("Failed to forcibly clean up all composed effect");
}
+
mActiveId = -1;
if (callback) {
diff --git a/vibrator/cs40l26/Vibrator.h b/vibrator/cs40l26/Vibrator.h
index 220c9741..27ee2837 100644
--- a/vibrator/cs40l26/Vibrator.h
+++ b/vibrator/cs40l26/Vibrator.h
@@ -154,6 +154,9 @@ class Vibrator : public BnVibrator {
binder_status_t dump(int fd, const char **args, uint32_t numArgs) override;
+ // SVC initialization time
+ static constexpr uint32_t MIN_ON_OFF_INTERVAL_US = 8500;
+
private:
ndk::ScopedAStatus on(uint32_t timeoutMs, uint32_t effectIndex, struct dspmem_chunk *ch,
const std::shared_ptr<IVibratorCallback> &callback);