sm8250-common: tri-state-key: Add hall sensor calibration support

Change-Id: I8449041eec5c8ab4153bd2942ebc7fda9ceb743e
This commit is contained in:
Hikari-no-Tenshi
2019-11-14 10:32:07 +02:00
committed by LuK1337
parent 2412a59d46
commit 19525f89df
5 changed files with 22 additions and 0 deletions

View File

@@ -16,6 +16,7 @@
#define LOG_TAG "tri-state-key_daemon"
#include <android-base/file.h>
#include <android-base/logging.h>
#include <fcntl.h>
#include <linux/input.h>
@@ -24,10 +25,15 @@
#include "uevent_listener.h"
#define HALL_CALIBRATION_DATA "/sys/devices/platform/soc/soc:tri_state_key/hall_data_calib"
#define HALL_PERSIST_CALIBRATION_DATA "/mnt/vendor/persist/engineermode/tri_state_hall_data"
#define KEY_MODE_NORMAL 601
#define KEY_MODE_VIBRATION 602
#define KEY_MODE_SILENCE 603
using android::base::ReadFileToString;
using android::base::WriteStringToFile;
using android::Uevent;
using android::UeventListener;
@@ -39,6 +45,11 @@ int main() {
LOG(INFO) << "Started";
if (std::string hallData; ReadFileToString(HALL_PERSIST_CALIBRATION_DATA, &hallData)) {
std::replace(hallData.begin(), hallData.end(), ';', ',');
WriteStringToFile(hallData, HALL_CALIBRATION_DATA);
}
uinputFd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
if (uinputFd < 0) {
LOG(ERROR) << "Unable to open uinput node";