diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-08-01 16:42:33 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-08-01 16:42:33 +0000 |
commit | ca62fc7d1251afa5e50934aa2bc55599e3664277 (patch) | |
tree | 2fdb1ac22c3806a6c8174a8d08e651bc6ed5452f | |
parent | 653b9924d33d419e66dfb808716f4cde842e3ca8 (diff) | |
parent | 2dc836a07ba3b2ce5732841a391e63fbb57c2b64 (diff) | |
download | device_google_wahoo-ca62fc7d1251afa5e50934aa2bc55599e3664277.tar.gz device_google_wahoo-ca62fc7d1251afa5e50934aa2bc55599e3664277.tar.bz2 device_google_wahoo-ca62fc7d1251afa5e50934aa2bc55599e3664277.zip |
Merge "haptics: enable low-power trigger mode for edge sense" into oc-dr1-dev
-rw-r--r-- | init.hardware.rc | 1 | ||||
-rw-r--r-- | vibrator/Vibrator.cpp | 12 | ||||
-rw-r--r-- | vibrator/Vibrator.h | 3 | ||||
-rw-r--r-- | vibrator/service.cpp | 9 |
4 files changed, 21 insertions, 4 deletions
diff --git a/init.hardware.rc b/init.hardware.rc index 9b2eed10..41ae2922 100644 --- a/init.hardware.rc +++ b/init.hardware.rc @@ -410,6 +410,7 @@ on early-boot chown system system /sys/class/leds/vibrator/device/ctrl_loop chown system system /sys/class/leds/vibrator/device/ol_lra_period chown system system /sys/class/leds/vibrator/device/autocal + chown system system /sys/class/leds/vibrator/device/lp_trigger_effect # Permission for LED driver chown system system /sys/class/leds/red/on_off_ms diff --git a/vibrator/Vibrator.cpp b/vibrator/Vibrator.cpp index b6804dbd..db64bb13 100644 --- a/vibrator/Vibrator.cpp +++ b/vibrator/Vibrator.cpp @@ -63,7 +63,7 @@ using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength; Vibrator::Vibrator(std::ofstream&& activate, std::ofstream&& duration, std::ofstream&& state, std::ofstream&& rtpinput, std::ofstream&& mode, std::ofstream&& sequencer, - std::ofstream&& scale, std::ofstream&& ctrlloop) : + std::ofstream&& scale, std::ofstream&& ctrlloop, std::ofstream&& lptrigger) : mActivate(std::move(activate)), mDuration(std::move(duration)), mState(std::move(state)), @@ -71,10 +71,18 @@ Vibrator::Vibrator(std::ofstream&& activate, std::ofstream&& duration, mMode(std::move(mode)), mSequencer(std::move(sequencer)), mScale(std::move(scale)), - mCtrlLoop(std::move(ctrlloop)) { + mCtrlLoop(std::move(ctrlloop)), + mLpTriggerEffect(std::move(lptrigger)) { mClickDuration = property_get_int32("ro.vibrator.hal.click.duration", WAVEFORM_CLICK_EFFECT_MS); mTickDuration = property_get_int32("ro.vibrator.hal.tick.duration", WAVEFORM_TICK_EFFECT_MS); + + // This enables effect #1 from the waveform library to be triggered by SLPI + // while the AP is in suspend mode + mLpTriggerEffect << 1 << std::endl; + if (!mLpTriggerEffect) { + ALOGW("Failed to set LP trigger mode (%d): %s", errno, strerror(errno)); + } } Return<Status> Vibrator::on(uint32_t timeoutMs, bool forceOpenLoop, bool isWaveform) { diff --git a/vibrator/Vibrator.h b/vibrator/Vibrator.h index 920fb3e6..82d4da20 100644 --- a/vibrator/Vibrator.h +++ b/vibrator/Vibrator.h @@ -32,7 +32,7 @@ public: Vibrator(std::ofstream&& activate, std::ofstream&& duration, std::ofstream&& state, std::ofstream&& rtpinput, std::ofstream&& mode, std::ofstream&& sequencer, - std::ofstream&& scale, std::ofstream&& ctrlloop); + std::ofstream&& scale, std::ofstream&& ctrlloop, std::ofstream&& lptrigger); // Methods from ::android::hardware::vibrator::V1_0::IVibrator follow. using Status = ::android::hardware::vibrator::V1_0::Status; @@ -56,6 +56,7 @@ private: std::ofstream mSequencer; std::ofstream mScale; std::ofstream mCtrlLoop; + std::ofstream mLpTriggerEffect; int32_t mClickDuration; int32_t mTickDuration; }; diff --git a/vibrator/service.cpp b/vibrator/service.cpp index 44577d73..c3af647b 100644 --- a/vibrator/service.cpp +++ b/vibrator/service.cpp @@ -39,6 +39,7 @@ static constexpr char MODE_PATH[] = "/sys/class/leds/vibrator/device/mode"; static constexpr char SEQUENCER_PATH[] = "/sys/class/leds/vibrator/device/set_sequencer"; static constexpr char SCALE_PATH[] = "/sys/class/leds/vibrator/device/scale"; static constexpr char CTRL_LOOP_PATH[] = "/sys/class/leds/vibrator/device/ctrl_loop"; +static constexpr char LP_TRIGGER_PATH[] = "/sys/class/leds/vibrator/device/lp_trigger_effect"; // File path to the calibration file static constexpr char CALIBRATION_FILEPATH[] = "/persist/haptics/drv2624.cal"; @@ -178,13 +179,19 @@ status_t registerVibratorService() { ALOGW("Failed to open %s (%d): %s", CTRL_LOOP_PATH, error, strerror(error)); } + std::ofstream lptrigger{LP_TRIGGER_PATH}; + if (!lptrigger) { + int error = errno; + ALOGW("Failed to open %s (%d): %s", LP_TRIGGER_PATH, error, strerror(error)); + } + if (!loadCalibrationData()) { ALOGW("Failed load calibration data"); } sp<IVibrator> vibrator = new Vibrator(std::move(activate), std::move(duration), std::move(state), std::move(rtpinput), std::move(mode), - std::move(sequencer), std::move(scale), std::move(ctrlloop)); + std::move(sequencer), std::move(scale), std::move(ctrlloop), std::move(lptrigger)); vibrator->registerAsService(); |