summaryrefslogtreecommitdiff
path: root/vibrator
diff options
context:
space:
mode:
authorchasewu <chasewu@google.com>2018-09-06 00:32:39 +0800
committerchasewu <chasewu@google.com>2018-09-20 20:22:01 +0800
commit6a97debd5a2157f57e1141c0bce696768a0094f8 (patch)
tree0db536c081522e862f44259c3e9ef6760694e723 /vibrator
parentdeca2cc151384667df4098ec69318bd12f0683d0 (diff)
downloadbonito-6a97debd5a2157f57e1141c0bce696768a0094f8.tar.gz
haptics: Modify haptics operating mode to force open loop
From HW's request, B4S4 only support open loop mode due to the actuator module. Bug: 113640889 Test: manual haptics test pass and loop mode checking Change-Id: I5102331dc1c0c2d53921655ce2c65546a8fa3a3c Signed-off-by: chasewu <chasewu@google.com>
Diffstat (limited to 'vibrator')
-rw-r--r--vibrator/Vibrator.cpp22
-rw-r--r--vibrator/Vibrator.h2
2 files changed, 8 insertions, 16 deletions
diff --git a/vibrator/Vibrator.cpp b/vibrator/Vibrator.cpp
index 96576848..002dd869 100644
--- a/vibrator/Vibrator.cpp
+++ b/vibrator/Vibrator.cpp
@@ -42,6 +42,8 @@ static constexpr int8_t MIN_RTP_INPUT = 0;
static constexpr char RTP_MODE[] = "rtp";
static constexpr char WAVEFORM_MODE[] = "waveform";
+static constexpr uint32_t LOOP_MODE_OPEN = 1;
+
// Use effect #1 in the waveform library for CLICK effect
static constexpr char WAVEFORM_CLICK_EFFECT_SEQ[] = "1 0";
static constexpr int32_t WAVEFORM_CLICK_EFFECT_MS = 6;
@@ -58,9 +60,6 @@ static constexpr uint32_t WAVEFORM_DOUBLE_CLICK_EFFECT_MS = 135;
static constexpr char WAVEFORM_HEAVY_CLICK_EFFECT_SEQ[] = "4 0";
static constexpr uint32_t WAVEFORM_HEAVY_CLICK_EFFECT_MS = 8;
-// Timeout threshold for selecting open or closed loop mode
-static constexpr int8_t LOOP_MODE_THRESHOLD_MS = 20;
-
using Status = ::android::hardware::vibrator::V1_0::Status;
using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength;
@@ -91,16 +90,9 @@ Vibrator::Vibrator(std::ofstream&& activate, std::ofstream&& duration,
}
}
-Return<Status> Vibrator::on(uint32_t timeoutMs, bool forceOpenLoop, bool isWaveform) {
- uint32_t loopMode = 1;
-
- // Open-loop mode is used for short click for over-drive
- // Close-loop mode is used for long notification for stability
- if (!forceOpenLoop && timeoutMs > LOOP_MODE_THRESHOLD_MS) {
- loopMode = 0;
- }
-
- mCtrlLoop << loopMode << std::endl;
+Return<Status> Vibrator::on(uint32_t timeoutMs, bool isWaveform) {
+ // Bonito / Sargo only support open-loop mode
+ mCtrlLoop << LOOP_MODE_OPEN << std::endl;
mDuration << timeoutMs << std::endl;
if (!mDuration) {
ALOGE("Failed to set duration (%d): %s", errno, strerror(errno));
@@ -124,7 +116,7 @@ Return<Status> Vibrator::on(uint32_t timeoutMs, bool forceOpenLoop, bool isWavef
// Methods from ::android::hardware::vibrator::V1_2::IVibrator follow.
Return<Status> Vibrator::on(uint32_t timeoutMs) {
- return on(timeoutMs, false /* forceOpenLoop */, false /* isWaveform */);
+ return on(timeoutMs, false /* isWaveform */);
}
Return<Status> Vibrator::off() {
@@ -214,7 +206,7 @@ Return<void> Vibrator::performEffect(Effect effect, EffectStrength strength, per
return Void();
}
mScale << convertEffectStrength(strength) << std::endl;
- on(timeMS, true /* forceOpenLoop */, true /* isWaveform */);
+ on(timeMS, true /* isWaveform */);
_hidl_cb(status, timeMS);
return Void();
}
diff --git a/vibrator/Vibrator.h b/vibrator/Vibrator.h
index f9daf7cd..ed6568c7 100644
--- a/vibrator/Vibrator.h
+++ b/vibrator/Vibrator.h
@@ -49,7 +49,7 @@ public:
Return<void> perform_1_2(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override;
private:
- Return<Status> on(uint32_t timeoutMs, bool forceOpenLoop, bool isWaveform);
+ Return<Status> on(uint32_t timeoutMs, bool isWaveform);
Return<void> performEffect(Effect effect, EffectStrength strength, perform_cb _hidl_cb);
std::ofstream mActivate;
std::ofstream mDuration;