From 67fcc3219a0c1db037de30fb5fe2caa034b44988 Mon Sep 17 00:00:00 2001 From: Simon1511 Date: Mon, 1 Nov 2021 16:14:55 +0100 Subject: [PATCH] sm7125: vibrator: Write directly to enable path instead of intensity path *Newer Samsung devices seem to control vibration intensity through /sys/class/timed_output/vibrator/enable instead of having a seperate node for intensity *Therefore we need to write to the enable path instead *Also set minimum intensity to 40 since that's the lowest value that's still noticeable Signed-off-by: Simon1511 Change-Id: I402c5e0e77549ae8be38c43544357b1c4e847880 --- vibrator/Vibrator.cpp | 13 ++++++++----- vibrator/Vibrator.h | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/vibrator/Vibrator.cpp b/vibrator/Vibrator.cpp index 89ac690..8e3dd8c 100644 --- a/vibrator/Vibrator.cpp +++ b/vibrator/Vibrator.cpp @@ -104,11 +104,7 @@ Return Vibrator::setAmplitude(uint8_t amplitude) { } LOG(DEBUG) << "setting intensity: " << intensity; - if (mhasTimedOutIntensity) { - return writeNode(VIBRATOR_INTENSITY_PATH, intensity); - } - - return Status::OK; + return writeNode(VIBRATOR_TIMEOUT_PATH, intensity); } Return Vibrator::perform(V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb) { @@ -196,6 +192,13 @@ Status Vibrator::activate(uint32_t timeoutMs) { return Status::UNSUPPORTED_OPERATION; } + /* We mostly get values that are 20ms and lower, but + that's not enough to be actually noticeable. Set it to + 40ms if timeoutMs is less than that. */ + if (timeoutMs < INTENSITY_MIN) { + timeoutMs = INTENSITY_MIN; + } + return writeNode(VIBRATOR_TIMEOUT_PATH, timeoutMs); } diff --git a/vibrator/Vibrator.h b/vibrator/Vibrator.h index aba75f5..c553bc0 100644 --- a/vibrator/Vibrator.h +++ b/vibrator/Vibrator.h @@ -22,9 +22,9 @@ #include -#define INTENSITY_MIN 1000 +#define INTENSITY_MIN 40 #define INTENSITY_MAX 10000 -#define INENSITY_DEFAULT INTENSITY_MAX +#define INTENSITY_DEFAULT INTENSITY_MAX #define CLICK_TIMING_MS 20