summaryrefslogtreecommitdiff
path: root/vibrator
diff options
context:
space:
mode:
authorchasewu <chasewu@google.com>2018-08-15 11:23:32 +0800
committerChase Wu <chasewu@google.com>2018-08-24 03:39:25 +0000
commitefae2580cec0fa9c86818187483349e368e7e210 (patch)
tree1c462f6b47a7ba314dfd9ef6558ce9057941f263 /vibrator
parentd1d6e5f9546c018f5eb62f4910ee7f98496f9012 (diff)
downloadbonito-efae2580cec0fa9c86818187483349e368e7e210.tar.gz
haptics: modify vibrator HAL to Walleye version
Pulled the source from following commit. (commit 811d138338cdc049749487963e48abe55b0b6093) Author: David Lin <dtwlin@google.com> Date: Tue Apr 17 10:29:18 2018 -0700 haptics: Implement constant effect for heavy click This patch implements support for heavy click effect which has the following UX requirements: - 8 ms in square wave and full amplitude for Walleye - 12 ms in square wave and full amplitude for Taimen Bug: 112975303 Test: build pass and manual haptics test. Change-Id: Iefc7920e43fa5cb0fa2791d712e7c8132301a538 Signed-off-by: chasewu <chasewu@google.com>
Diffstat (limited to 'vibrator')
-rw-r--r--vibrator/Vibrator.cpp281
-rw-r--r--vibrator/Vibrator.h21
-rw-r--r--vibrator/service.cpp120
3 files changed, 212 insertions, 210 deletions
diff --git a/vibrator/Vibrator.cpp b/vibrator/Vibrator.cpp
index 2193930e..96576848 100644
--- a/vibrator/Vibrator.cpp
+++ b/vibrator/Vibrator.cpp
@@ -36,86 +36,95 @@ namespace vibrator {
namespace V1_2 {
namespace implementation {
-using Status = ::android::hardware::vibrator::V1_0::Status;
-using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength;
-
-static constexpr uint32_t WAVEFORM_TICK_EFFECT_INDEX = 2;
-static constexpr uint32_t WAVEFORM_TICK_EFFECT_MS = 9;
-
-static constexpr uint32_t WAVEFORM_CLICK_EFFECT_INDEX = 3;
-static constexpr uint32_t WAVEFORM_CLICK_EFFECT_MS = 9;
-
-static constexpr uint32_t WAVEFORM_HEAVY_CLICK_EFFECT_INDEX = 4;
-static constexpr uint32_t WAVEFORM_HEAVY_CLICK_EFFECT_MS = 9;
-static constexpr uint32_t WAVEFORM_STRONG_HEAVY_CLICK_EFFECT_MS = 12;
-
-static constexpr uint32_t WAVEFORM_DOUBLE_CLICK_EFFECT_INDEX = 7;
-static constexpr uint32_t WAVEFORM_DOUBLE_CLICK_EFFECT_MS = 130;
-
-static constexpr uint32_t WAVEFORM_RINGTONE_EFFECT_INDEX = 65534;
-static constexpr uint32_t WAVEFORM_RINGTONE_EFFECT_MS = 30000;
-
-// The_big_adventure - RINGTONE_1
-static constexpr char WAVEFORM_RINGTONE1_EFFECT_QUEUE[] = "160, 11.100, 2744, 1!";
-
-// Copycat - RINGTONE_2
-static constexpr char WAVEFORM_RINGTONE2_EFFECT_QUEUE[] = "260, 12.100, 716, 2!";
+static constexpr int8_t MAX_RTP_INPUT = 127;
+static constexpr int8_t MIN_RTP_INPUT = 0;
-// Crackle - RINGTONE_3
-static constexpr char WAVEFORM_RINGTONE3_EFFECT_QUEUE[] = "404, 13.100, 628, 5!";
+static constexpr char RTP_MODE[] = "rtp";
+static constexpr char WAVEFORM_MODE[] = "waveform";
-// Flutterby - RINGTONE_4
-static constexpr char WAVEFORM_RINGTONE4_EFFECT_QUEUE[] = "14.100, 6!";
+// 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;
-// Hotline - RINGTONE_5
-static constexpr char WAVEFORM_RINGTONE5_EFFECT_QUEUE[] = "15.100, 4!";
+// Use effect #2 in the waveform library for TICK effect
+static constexpr char WAVEFORM_TICK_EFFECT_SEQ[] = "2 0";
+static constexpr int32_t WAVEFORM_TICK_EFFECT_MS = 2;
-// Leaps_and_bounds - RINGTONE_6
-static constexpr char WAVEFORM_RINGTONE6_EFFECT_QUEUE[] = "140, 16.100, 1!";
+// Use effect #3 in the waveform library for DOUBLE_CLICK effect
+static constexpr char WAVEFORM_DOUBLE_CLICK_EFFECT_SEQ[] = "3 0";
+static constexpr uint32_t WAVEFORM_DOUBLE_CLICK_EFFECT_MS = 135;
-// Lollipop - RINGTONE_7
-static constexpr char WAVEFORM_RINGTONE7_EFFECT_QUEUE[] = "140, 17.100, 624, 1!";
+// Use effect #4 in the waveform library for HEAVY_CLICK effect
+static constexpr char WAVEFORM_HEAVY_CLICK_EFFECT_SEQ[] = "4 0";
+static constexpr uint32_t WAVEFORM_HEAVY_CLICK_EFFECT_MS = 8;
-// Lost_and_found - RINGTONE_8
-static constexpr char WAVEFORM_RINGTONE8_EFFECT_QUEUE[] = "140, 18.100, 1020,496, 1!";
+// Timeout threshold for selecting open or closed loop mode
+static constexpr int8_t LOOP_MODE_THRESHOLD_MS = 20;
-// Mash_up - RINGTONE_9
-static constexpr char WAVEFORM_RINGTONE9_EFFECT_QUEUE[] = "140, 19.100, 8, 3!";
-
-// Monkey_around - RINGTONE_10
-static constexpr char WAVEFORM_RINGTONE10_EFFECT_QUEUE[] = "20.100, 23.100, 23.80, 23.60, 892, 4!";
+using Status = ::android::hardware::vibrator::V1_0::Status;
+using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength;
-// Schools_out - RINGTONE_11
-static constexpr char WAVEFORM_RINGTONE11_EFFECT_QUEUE[] = "21.60, 21.80, 21.100, 1020, 564, 6!";
+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&& lptrigger) :
+ mActivate(std::move(activate)),
+ mDuration(std::move(duration)),
+ mState(std::move(state)),
+ mRtpInput(std::move(rtpinput)),
+ mMode(std::move(mode)),
+ mSequencer(std::move(sequencer)),
+ mScale(std::move(scale)),
+ 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);
+ mHeavyClickDuration = property_get_int32(
+ "ro.vibrator.hal.heavyclick.duration", WAVEFORM_HEAVY_CLICK_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));
+ }
+}
-// Zen_too - RINGTONE_12
-static constexpr char WAVEFORM_RINGTONE12_EFFECT_QUEUE[] = "140, 22.100, 972, 1!";
+Return<Status> Vibrator::on(uint32_t timeoutMs, bool forceOpenLoop, bool isWaveform) {
+ uint32_t loopMode = 1;
-static constexpr int8_t MAX_SCALE_INPUT = 112;
+ // 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;
+ }
-static constexpr int8_t MAX_TRIGGER_LATENCY_MS = 5;
+ mCtrlLoop << loopMode << std::endl;
+ mDuration << timeoutMs << std::endl;
+ if (!mDuration) {
+ ALOGE("Failed to set duration (%d): %s", errno, strerror(errno));
+ return Status::UNKNOWN_ERROR;
+ }
-Vibrator::Vibrator(std::ofstream&& activate, std::ofstream&& duration, std::ofstream&& effect,
- std::ofstream&& queue, std::ofstream&& scale) :
- mActivate(std::move(activate)),
- mDuration(std::move(duration)),
- mEffectIndex(std::move(effect)),
- mEffectQueue(std::move(queue)),
- mScale(std::move(scale))
-{}
+ if (isWaveform) {
+ mMode << WAVEFORM_MODE << std::endl;
+ } else {
+ mMode << RTP_MODE << std::endl;
+ }
-Return<Status> Vibrator::on(uint32_t timeoutMs, uint32_t effectIndex) {
- mEffectIndex << effectIndex << std::endl;
- mDuration << timeoutMs << std::endl;
mActivate << 1 << std::endl;
+ if (!mActivate) {
+ ALOGE("Failed to activate (%d): %s", errno, strerror(errno));
+ return Status::UNKNOWN_ERROR;
+ }
- return Status::OK;
+ return Status::OK;
}
-
-// Methods from ::android::hardware::vibrator::V1_1::IVibrator follow.
+// Methods from ::android::hardware::vibrator::V1_2::IVibrator follow.
Return<Status> Vibrator::on(uint32_t timeoutMs) {
- return on(timeoutMs, 0);
+ return on(timeoutMs, false /* forceOpenLoop */, false /* isWaveform */);
}
Return<Status> Vibrator::off() {
@@ -128,14 +137,21 @@ Return<Status> Vibrator::off() {
}
Return<bool> Vibrator::supportsAmplitudeControl() {
- return (mScale ? true : false);
+ return (mRtpInput ? true : false);
}
Return<Status> Vibrator::setAmplitude(uint8_t amplitude) {
- int32_t scale = MAX_SCALE_INPUT - std::round((amplitude - 1) / 254.0 * MAX_SCALE_INPUT);
- mScale << scale << std::endl;
- if (!mScale) {
+ if (amplitude == 0) {
+ return Status::BAD_VALUE;
+ }
+
+ int32_t rtp_input =
+ std::round((amplitude - 1) / 254.0 * (MAX_RTP_INPUT - MIN_RTP_INPUT) +
+ MIN_RTP_INPUT);
+
+ mRtpInput << rtp_input << std::endl;
+ if (!mRtpInput) {
ALOGE("Failed to set amplitude (%d): %s", errno, strerror(errno));
return Status::UNKNOWN_ERROR;
}
@@ -143,8 +159,23 @@ Return<Status> Vibrator::setAmplitude(uint8_t amplitude) {
return Status::OK;
}
-Return<void> Vibrator::perform(V1_0::Effect effect, EffectStrength strength,
- perform_cb _hidl_cb) {
+static uint8_t convertEffectStrength(EffectStrength strength) {
+ uint8_t scale;
+
+ switch (strength) {
+ case EffectStrength::LIGHT:
+ scale = 2; // 50%
+ break;
+ case EffectStrength::MEDIUM:
+ case EffectStrength::STRONG:
+ scale = 0; // 100%
+ break;
+ }
+
+ return scale;
+}
+
+Return<void> Vibrator::perform(V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
return performEffect(static_cast<Effect>(effect), strength, _hidl_cb);
}
@@ -153,118 +184,38 @@ Return<void> Vibrator::perform_1_1(V1_1::Effect_1_1 effect, EffectStrength stren
return performEffect(static_cast<Effect>(effect), strength, _hidl_cb);
}
-Return<void> Vibrator::perform_1_2(Effect effect, EffectStrength strength,
- perform_cb _hidl_cb) {
- return performEffect(effect, strength, _hidl_cb);
+Return<void> Vibrator::perform_1_2(Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
+ return performEffect(static_cast<Effect>(effect), strength, _hidl_cb);
}
-Return<void> Vibrator::performEffect(Effect effect, EffectStrength strength,
- perform_cb _hidl_cb) {
+Return<void> Vibrator::performEffect(Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
Status status = Status::OK;
- uint32_t timeMs;
- uint32_t effectIndex;
+ uint32_t timeMS;
switch (effect) {
- case Effect::TICK:
- effectIndex = WAVEFORM_TICK_EFFECT_INDEX;
- timeMs = WAVEFORM_TICK_EFFECT_MS;
- break;
case Effect::CLICK:
- effectIndex = WAVEFORM_CLICK_EFFECT_INDEX;
- timeMs = WAVEFORM_CLICK_EFFECT_MS;
- break;
- case Effect::HEAVY_CLICK:
- effectIndex = WAVEFORM_HEAVY_CLICK_EFFECT_INDEX;
- if (strength == EffectStrength::STRONG) {
- timeMs = WAVEFORM_STRONG_HEAVY_CLICK_EFFECT_MS;
- } else {
- timeMs = WAVEFORM_HEAVY_CLICK_EFFECT_MS;
- }
+ mSequencer << WAVEFORM_CLICK_EFFECT_SEQ << std::endl;
+ timeMS = mClickDuration;
break;
case Effect::DOUBLE_CLICK:
- effectIndex = WAVEFORM_DOUBLE_CLICK_EFFECT_INDEX;
- timeMs = WAVEFORM_DOUBLE_CLICK_EFFECT_MS;
- break;
- case Effect::RINGTONE_1:
- mEffectQueue << WAVEFORM_RINGTONE1_EFFECT_QUEUE << std::endl;
+ mSequencer << WAVEFORM_DOUBLE_CLICK_EFFECT_SEQ << std::endl;
+ timeMS = WAVEFORM_DOUBLE_CLICK_EFFECT_MS;
break;
- case Effect::RINGTONE_2:
- mEffectQueue << WAVEFORM_RINGTONE2_EFFECT_QUEUE << std::endl;
- break;
- case Effect::RINGTONE_3:
- mEffectQueue << WAVEFORM_RINGTONE3_EFFECT_QUEUE << std::endl;
- break;
- case Effect::RINGTONE_4:
- mEffectQueue << WAVEFORM_RINGTONE4_EFFECT_QUEUE << std::endl;
- break;
- case Effect::RINGTONE_5:
- mEffectQueue << WAVEFORM_RINGTONE5_EFFECT_QUEUE << std::endl;
- break;
- case Effect::RINGTONE_6:
- mEffectQueue << WAVEFORM_RINGTONE6_EFFECT_QUEUE << std::endl;
- break;
- case Effect::RINGTONE_7:
- mEffectQueue << WAVEFORM_RINGTONE7_EFFECT_QUEUE << std::endl;
- break;
- case Effect::RINGTONE_8:
- mEffectQueue << WAVEFORM_RINGTONE8_EFFECT_QUEUE << std::endl;
- break;
- case Effect::RINGTONE_9:
- mEffectQueue << WAVEFORM_RINGTONE9_EFFECT_QUEUE << std::endl;
- break;
- case Effect::RINGTONE_10:
- mEffectQueue << WAVEFORM_RINGTONE10_EFFECT_QUEUE << std::endl;
- break;
- case Effect::RINGTONE_11:
- mEffectQueue << WAVEFORM_RINGTONE11_EFFECT_QUEUE << std::endl;
+ case Effect::TICK:
+ mSequencer << WAVEFORM_TICK_EFFECT_SEQ << std::endl;
+ timeMS = mTickDuration;
break;
- case Effect::RINGTONE_12:
- mEffectQueue << WAVEFORM_RINGTONE12_EFFECT_QUEUE << std::endl;
+ case Effect::HEAVY_CLICK:
+ mSequencer << WAVEFORM_HEAVY_CLICK_EFFECT_SEQ << std::endl;
+ timeMS = mHeavyClickDuration;
break;
default:
_hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
return Void();
}
-
- // EffectStrength needs to be handled differently for ringtone effects
- if (effect >= Effect::RINGTONE_1 && effect <= Effect::RINGTONE_15) {
- effectIndex = WAVEFORM_RINGTONE_EFFECT_INDEX;
- timeMs = WAVEFORM_RINGTONE_EFFECT_MS;
- switch (strength) {
- case EffectStrength::LIGHT:
- setAmplitude(UINT8_MAX / 3);
- break;
- case EffectStrength::MEDIUM:
- setAmplitude(UINT8_MAX / 2);
- break;
- case EffectStrength::STRONG:
- setAmplitude(UINT8_MAX);
- break;
- default:
- _hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
- return Void();
- }
- } else {
- switch (strength) {
- case EffectStrength::LIGHT:
- effectIndex -= 1;
- break;
- case EffectStrength::MEDIUM:
- break;
- case EffectStrength::STRONG:
- effectIndex += 1;
- break;
- default:
- _hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
- return Void();
- }
- timeMs += MAX_TRIGGER_LATENCY_MS; // Add expected cold-start latency
- setAmplitude(UINT8_MAX); // Always set full-scale for non-ringtone constants
- }
-
- on(timeMs, effectIndex);
- _hidl_cb(status, timeMs);
-
+ mScale << convertEffectStrength(strength) << std::endl;
+ on(timeMS, true /* forceOpenLoop */, true /* isWaveform */);
+ _hidl_cb(status, timeMS);
return Void();
}
diff --git a/vibrator/Vibrator.h b/vibrator/Vibrator.h
index 05f81aee..f9daf7cd 100644
--- a/vibrator/Vibrator.h
+++ b/vibrator/Vibrator.h
@@ -29,8 +29,10 @@ namespace implementation {
class Vibrator : public IVibrator {
public:
- Vibrator(std::ofstream&& activate, std::ofstream&& duration, std::ofstream&& effect,
- std::ofstream&& queue, std::ofstream&& scale);
+ 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&& lptrigger);
// Methods from ::android::hardware::vibrator::V1_0::IVibrator follow.
using Status = ::android::hardware::vibrator::V1_0::Status;
@@ -47,16 +49,23 @@ public:
Return<void> perform_1_2(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override;
private:
- Return<Status> on(uint32_t timeoutMs, uint32_t effectIndex);
+ Return<Status> on(uint32_t timeoutMs, bool forceOpenLoop, bool isWaveform);
Return<void> performEffect(Effect effect, EffectStrength strength, perform_cb _hidl_cb);
std::ofstream mActivate;
std::ofstream mDuration;
- std::ofstream mEffectIndex;
- std::ofstream mEffectQueue;
+ std::ofstream mState;
+ std::ofstream mRtpInput;
+ std::ofstream mMode;
+ std::ofstream mSequencer;
std::ofstream mScale;
+ std::ofstream mCtrlLoop;
+ std::ofstream mLpTriggerEffect;
+ int32_t mClickDuration;
+ int32_t mTickDuration;
+ int32_t mHeavyClickDuration;
};
} // namespace implementation
-} // namespace V1_1
+} // namespace V1_2
} // namespace vibrator
} // namespace hardware
} // namespace android
diff --git a/vibrator/service.cpp b/vibrator/service.cpp
index 953f75d9..7b280561 100644
--- a/vibrator/service.cpp
+++ b/vibrator/service.cpp
@@ -29,22 +29,26 @@ using android::hardware::vibrator::V1_2::IVibrator;
using android::hardware::vibrator::V1_2::implementation::Vibrator;
using namespace android;
+// Refer to Documentation/ABI/testing/sysfs-class-led-driver-drv2624
+// kernel documentation on the detail usages for ABIs below
static constexpr char ACTIVATE_PATH[] = "/sys/class/leds/vibrator/activate";
static constexpr char DURATION_PATH[] = "/sys/class/leds/vibrator/duration";
static constexpr char STATE_PATH[] = "/sys/class/leds/vibrator/state";
-static constexpr char EFFECT_INDEX_PATH[] = "/sys/class/leds/vibrator/device/cp_trigger_index";
-static constexpr char EFFECT_QUEUE_PATH[] = "/sys/class/leds/vibrator/device/cp_trigger_queue";
-static constexpr char DIGI_SCALE_PATH[] = "/sys/class/leds/vibrator/device/dig_scale";
+static constexpr char RTP_INPUT_PATH[] = "/sys/class/leds/vibrator/device/rtp_input";
+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/cs40l20.cal";
+static constexpr char CALIBRATION_FILEPATH[] = "/persist/haptics/drv2624.cal";
// Kernel ABIs for updating the calibration data
-static constexpr char F0_CONFIG[] = "f0_measured";
-static constexpr char REDC_CONFIG[] = "redc_measured";
-static constexpr char F0_FILEPATH[] = "/sys/class/leds/vibrator/device/f0_stored";
-static constexpr char REDC_FILEPATH[] = "/sys/class/leds/vibrator/device/redc_stored";
-
+static constexpr char AUTOCAL_CONFIG[] = "autocal";
+static constexpr char LRA_PERIOD_CONFIG[] = "lra_period";
+static constexpr char AUTOCAL_FILEPATH[] = "/sys/class/leds/vibrator/device/autocal";
+static constexpr char OL_LRA_PERIOD_FILEPATH[] = "/sys/class/leds/vibrator/device/ol_lra_period";
static std::string trim(const std::string& str,
const std::string& whitespace = " \t") {
@@ -62,26 +66,33 @@ static std::string trim(const std::string& str,
static bool loadCalibrationData() {
std::map<std::string, std::string> config_data;
- std::ofstream f0{F0_FILEPATH};
- if (!f0) {
- ALOGE("Failed to open %s (%d): %s", F0_FILEPATH, errno,
- strerror(errno));
+ std::ofstream autocal{AUTOCAL_FILEPATH};
+ if (!autocal) {
+ int error = errno;
+ ALOGE("Failed to open %s (%d): %s", AUTOCAL_FILEPATH, error,
+ strerror(error));
+ return false;
}
- std::ofstream redc{REDC_FILEPATH};
- if (!redc) {
- ALOGE("Failed to open %s (%d): %s", REDC_FILEPATH, errno,
- strerror(errno));
+ std::ofstream ol_lra_period{OL_LRA_PERIOD_FILEPATH};
+ if (!ol_lra_period) {
+ int error = errno;
+ ALOGE("Failed to open %s (%d): %s", OL_LRA_PERIOD_FILEPATH, error,
+ strerror(error));
+ return false;
}
std::ifstream cal_data{CALIBRATION_FILEPATH};
if (!cal_data) {
- ALOGE("Failed to open %s (%d): %s", CALIBRATION_FILEPATH, errno,
- strerror(errno));
+ int error = errno;
+ ALOGE("Failed to open %s (%d): %s", CALIBRATION_FILEPATH, error,
+ strerror(error));
return false;
}
- for (std::string line; std::getline(cal_data, line);) {
+ std::string line;
+
+ while (std::getline(cal_data, line)) {
if (line.empty() || line[0] == '#') {
continue;
}
@@ -96,12 +107,12 @@ static bool loadCalibrationData() {
}
}
- if(config_data.find(F0_CONFIG) != config_data.end()) {
- f0 << config_data[F0_CONFIG] << std::endl;
+ if(config_data.find(AUTOCAL_CONFIG) != config_data.end()) {
+ autocal << config_data[AUTOCAL_CONFIG] << std::endl;
}
- if(config_data.find(REDC_CONFIG) != config_data.end()) {
- redc << config_data[REDC_CONFIG] << std::endl;
+ if(config_data.find(LRA_PERIOD_CONFIG) != config_data.end()) {
+ ol_lra_period << config_data[LRA_PERIOD_CONFIG] << std::endl;
}
return true;
@@ -111,45 +122,76 @@ status_t registerVibratorService() {
// ostreams below are required
std::ofstream activate{ACTIVATE_PATH};
if (!activate) {
- ALOGE("Failed to open %s (%d): %s", ACTIVATE_PATH, errno, strerror(errno));
+ int error = errno;
+ ALOGE("Failed to open %s (%d): %s", ACTIVATE_PATH, error, strerror(error));
+ return -error;
}
std::ofstream duration{DURATION_PATH};
if (!duration) {
- ALOGE("Failed to open %s (%d): %s", DURATION_PATH, errno, strerror(errno));
+ int error = errno;
+ ALOGE("Failed to open %s (%d): %s", DURATION_PATH, error, strerror(error));
+ return -error;
}
std::ofstream state{STATE_PATH};
if (!state) {
- ALOGE("Failed to open %s (%d): %s", STATE_PATH, errno, strerror(errno));
+ int error = errno;
+ ALOGE("Failed to open %s (%d): %s", STATE_PATH, error, strerror(error));
+ return -error;
}
- std::ofstream effect{EFFECT_INDEX_PATH};
+ state << 1 << std::endl;
if (!state) {
- ALOGE("Failed to open %s (%d): %s", EFFECT_INDEX_PATH, errno, strerror(errno));
+ int error = errno;
+ ALOGE("Failed to set state (%d): %s", errno, strerror(errno));
+ return -error;
}
- std::ofstream queue{EFFECT_QUEUE_PATH};
- if (!state) {
- ALOGE("Failed to open %s (%d): %s", EFFECT_QUEUE_PATH, errno, strerror(errno));
+ // ostreams below are optional
+ std::ofstream rtpinput{RTP_INPUT_PATH};
+ if (!rtpinput) {
+ int error = errno;
+ ALOGW("Failed to open %s (%d): %s", RTP_INPUT_PATH, error, strerror(error));
+ }
+
+ std::ofstream mode{MODE_PATH};
+ if (!mode) {
+ int error = errno;
+ ALOGW("Failed to open %s (%d): %s", MODE_PATH, error, strerror(error));
+ }
+
+ std::ofstream sequencer{SEQUENCER_PATH};
+ if (!sequencer) {
+ int error = errno;
+ ALOGW("Failed to open %s (%d): %s", SEQUENCER_PATH, error, strerror(error));
}
- std::ofstream scale{DIGI_SCALE_PATH};
+ std::ofstream scale{SCALE_PATH};
if (!scale) {
- ALOGE("Failed to open %s (%d): %s", DIGI_SCALE_PATH, errno, strerror(errno));
+ int error = errno;
+ ALOGW("Failed to open %s (%d): %s", SCALE_PATH, error, strerror(error));
}
- state << 1 << std::endl;
- if (!state) {
- ALOGE("Failed to set state (%d): %s", errno, strerror(errno));
+ std::ofstream ctrlloop{CTRL_LOOP_PATH};
+ if (!ctrlloop) {
+ int error = errno;
+ 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 to load calibration data");
+ ALOGW("Failed load calibration data");
}
sp<IVibrator> vibrator = new Vibrator(std::move(activate), std::move(duration),
- std::move(effect), std::move(queue), std::move(scale));
+ std::move(state), std::move(rtpinput), std::move(mode),
+ std::move(sequencer), std::move(scale), std::move(ctrlloop), std::move(lptrigger));
return vibrator->registerAsService();
}