From 9f4c9b3752109e9640aad4560d15c0c2299df744 Mon Sep 17 00:00:00 2001 From: chasewu Date: Wed, 3 Jun 2020 14:21:47 +0800 Subject: [PATCH] vibrator: Dynamically support different HW stage device Since EVT and DVT devices were applied different target G values, we have to add a workaround to support this condition. Bug: 157610908 Bug: 157714236 Bug: 154788092 Test: manual check logs Signed-off-by: chasewu Change-Id: I5d534d44a6f765250f16a13cc7bb9ccecc120f99 --- vibrator/drv2624/Hardware.h | 4 ++++ vibrator/drv2624/Vibrator.cpp | 17 +++++++++++++++-- vibrator/drv2624/Vibrator.h | 2 ++ vibrator/drv2624/tests/mocks.h | 1 + 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/vibrator/drv2624/Hardware.h b/vibrator/drv2624/Hardware.h index 37f1a32..38a290a 100644 --- a/vibrator/drv2624/Hardware.h +++ b/vibrator/drv2624/Hardware.h @@ -194,6 +194,10 @@ class HwCal : public Vibrator::HwCal, private HwCalBase { bool getTriggerEffectSupport(uint32_t *value) override { return getProperty("lptrigger", value, DEFAULT_LP_TRIGGER_SUPPORT); } + bool getDevHwVer(std::string *value) override { + *value = ::android::base::GetProperty("ro.revision", "DVT"); + return true; + } void debug(int fd) override { HwCalBase::debug(fd); } }; diff --git a/vibrator/drv2624/Vibrator.cpp b/vibrator/drv2624/Vibrator.cpp index c56d474..c860afc 100644 --- a/vibrator/drv2624/Vibrator.cpp +++ b/vibrator/drv2624/Vibrator.cpp @@ -59,8 +59,8 @@ static constexpr char WAVEFORM_DOUBLE_CLICK_EFFECT_SEQ[] = "3 0"; static constexpr char WAVEFORM_HEAVY_CLICK_EFFECT_SEQ[] = "4 0"; // UT team design those target G values -static std::array EFFECT_TARGET_G = {0.15, 0.27, 0.32, 0.48, 0.62}; -static std::array STEADY_TARGET_G = {1.2, 1.145, 0.4}; +static std::array EFFECT_TARGET_G = {0.275, 0.63, 0.68, 0.97, 1.12}; +static std::array STEADY_TARGET_G = {1.9, 1.145, 0.73}; struct SensorContext { ASensorEventQueue *queue; @@ -311,11 +311,24 @@ Vibrator::Vibrator(std::unique_ptr hwapi, std::unique_ptr hwcal) float tempVolLevel = 0.0f, tempAmpMax = 0.0f; uint32_t longFreqencyShift = 0, shortVoltageMax = 0, longVoltageMax = 0, shape = 0; + std::string devHwVersion; mHwCal->getLongFrequencyShift(&longFreqencyShift); mHwCal->getShortVoltageMax(&shortVoltageMax); mHwCal->getLongVoltageMax(&longVoltageMax); + // TODO: This is a workaround for b/157610908 + mHwCal->getDevHwVer(&devHwVersion); + if (devHwVersion.compare("EVT")) { + EFFECT_TARGET_G = {0.15, 0.27, 0.35, 0.54, 0.65}; + STEADY_TARGET_G = {1.2, 1.145, 0.4}; + ALOGW("Device HW version: %s, this is an EVT device", + devHwVersion.c_str()); + } else { + ALOGW("Device HW version: %s, no need to change the target G values", + devHwVersion.c_str()); + } + hasEffectCoeffs = mHwCal->getEffectCoeffs(&effectCoeffs); hasExternalEffectG = mHwCal->getEffectTargetG(&externalEffectTargetG); for (i = 0; i < 5; i++) { diff --git a/vibrator/drv2624/Vibrator.h b/vibrator/drv2624/Vibrator.h index 0c593d4..7a93872 100644 --- a/vibrator/drv2624/Vibrator.h +++ b/vibrator/drv2624/Vibrator.h @@ -126,6 +126,8 @@ class Vibrator : public BnVibrator { virtual bool getSteadyShape(uint32_t *value) = 0; // Obtains the trigger effect support virtual bool getTriggerEffectSupport(uint32_t *value) = 0; + // Obtains device hardware version + virtual bool getDevHwVer(std::string *value) = 0; // Emit diagnostic information to the given file. virtual void debug(int fd) = 0; }; diff --git a/vibrator/drv2624/tests/mocks.h b/vibrator/drv2624/tests/mocks.h index e3b0229..945be70 100644 --- a/vibrator/drv2624/tests/mocks.h +++ b/vibrator/drv2624/tests/mocks.h @@ -61,6 +61,7 @@ class MockCal : public ::aidl::android::hardware::vibrator::Vibrator::HwCal { MOCK_METHOD1(getEffectShape, bool(uint32_t *value)); MOCK_METHOD1(getSteadyShape, bool(uint32_t *value)); MOCK_METHOD1(getTriggerEffectSupport, bool(uint32_t *value)); + MOCK_METHOD1(getDevHwVer, bool(std::string &value)); MOCK_METHOD1(debug, void(int fd)); ~MockCal() override { destructor(); };