[DO NOT MERGE] cs40l26: Enable vibrator manager feature
This patch remove the old dual design and add it into the original vibrator HALs'rc file. Also, this patch dynamically gets the service name from rc file. Bug: 181615889 Test: Manual type and trigger a long/short vibration Test: cmd vibrator_manager synced xxxx Test: cmd vibrator_manager sequential -v 0 xxxx Signed-off-by: Chase Wu <chasewu@google.com> Change-Id: I7a5dd65c67e01a008f8d2c675dc7b96599469622
This commit is contained in:
parent
3584a67955
commit
3f32520d2f
12 changed files with 95 additions and 92 deletions
|
@ -80,25 +80,6 @@ cc_binary {
|
|||
shared_libs: [
|
||||
"android.hardware.vibrator-impl.cs40l26-private",
|
||||
],
|
||||
cflags: [
|
||||
"-DLOG_TAG=\"android.hardware.vibrator-cs40l26-private\"",
|
||||
],
|
||||
proprietary: true,
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.vibrator-service.cs40l26-dual-private",
|
||||
defaults: ["VibratorHalCs40l26BinaryDefaultsPrivate"],
|
||||
init_rc: ["android.hardware.vibrator-service.cs40l26-dual-private.rc"],
|
||||
vintf_fragments: ["android.hardware.vibrator-service.cs40l26-dual-private.xml"],
|
||||
srcs: ["service.cpp"],
|
||||
shared_libs: [
|
||||
"android.hardware.vibrator-impl.cs40l26-private",
|
||||
],
|
||||
cflags: [
|
||||
"-DVIBRATOR_NAME=\"dual\"",
|
||||
"-DLOG_TAG=\"android.hardware.vibrator-cs40l26-dual-private\"",
|
||||
],
|
||||
proprietary: true,
|
||||
}
|
||||
|
||||
|
@ -111,8 +92,5 @@ cc_binary {
|
|||
shared_libs: [
|
||||
"android.hardware.vibrator-impl.cs40l26-private",
|
||||
],
|
||||
cflags: [
|
||||
"-DLOG_TAG=\"android.hardware.vibrator-cs40l26-stereo-private\"",
|
||||
],
|
||||
proprietary: true,
|
||||
}
|
||||
|
|
|
@ -54,13 +54,13 @@ class VibMgrHwApi : public VibratorManager::HwApi {
|
|||
}
|
||||
mGPIOPin = utils::getProperty(mPropertyPrefix + "gpio.num", DEBUG_GPI_PIN);
|
||||
if (mGPIOPin == DEBUG_GPI_PIN) {
|
||||
ALOGE("GetGPIO: Fail to get the GPIO num: %s", strerror(errno));
|
||||
ALOGE("GetGPIO: Failed to get the GPIO num: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
mGPIOShift = utils::getProperty(mPropertyPrefix + "gpio.shift", DEBUG_GPI_PIN_SHIFT);
|
||||
|
||||
if (mGPIOShift == DEBUG_GPI_PIN_SHIFT) {
|
||||
ALOGE("GetGPIO: Fail to get the GPIO shift num: %s", strerror(errno));
|
||||
ALOGE("GetGPIO: Failed to get the GPIO shift num: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,18 @@ static constexpr float PWLE_BW_MAP_SIZE =
|
|||
*/
|
||||
static constexpr uint32_t GPIO_TRIGGER_CONFIG = 0x9100;
|
||||
|
||||
const char *kHAPNAME = std::getenv("HAPTIC_NAME");
|
||||
#undef ALOGV
|
||||
#define ALOGV(...) ((void)ALOG(LOG_VERBOSE, kHAPNAME, __VA_ARGS__))
|
||||
#undef ALOGD
|
||||
#define ALOGD(...) ((void)ALOG(LOG_DEBUG, kHAPNAME, __VA_ARGS__))
|
||||
#undef ALOGI
|
||||
#define ALOGI(...) ((void)ALOG(LOG_INFO, kHAPNAME, __VA_ARGS__))
|
||||
#undef ALOGW
|
||||
#define ALOGW(...) ((void)ALOG(LOG_WARN, kHAPNAME, __VA_ARGS__))
|
||||
#undef ALOGE
|
||||
#define ALOGE(...) ((void)ALOG(LOG_ERROR, kHAPNAME, __VA_ARGS__))
|
||||
|
||||
static uint16_t amplitudeToScale(float amplitude, float maximum) {
|
||||
float ratio = 100; /* Unit: % */
|
||||
if (maximum != 0)
|
||||
|
@ -248,7 +260,7 @@ Vibrator::Vibrator(std::unique_ptr<HwApi> hwapi, std::unique_ptr<HwCal> hwcal)
|
|||
for (uint8_t retry = 0; retry < 10; retry++) {
|
||||
ret = glob(inputEventPathName, 0, nullptr, &inputEventPaths);
|
||||
if (ret) {
|
||||
ALOGE("Fail to get input event paths (%d): %s", errno, strerror(errno));
|
||||
ALOGE("Failed to get input event paths (%d): %s", errno, strerror(errno));
|
||||
} else {
|
||||
for (int i = 0; i < inputEventPaths.gl_pathc; i++) {
|
||||
fd = TEMP_FAILURE_RETRY(open(inputEventPaths.gl_pathv[i], O_RDWR));
|
||||
|
@ -278,7 +290,7 @@ Vibrator::Vibrator(std::unique_ptr<HwApi> hwapi, std::unique_ptr<HwCal> hwcal)
|
|||
}
|
||||
|
||||
if (!mInputFd.ok()) {
|
||||
ALOGE("Fail to get an input event with name %s", inputEventName);
|
||||
ALOGE("Failed to get an input event with name %s", inputEventName);
|
||||
}
|
||||
} else {
|
||||
ALOGE("The input name %s is not cs40l26_input or cs40l26_dual_input", inputEventName);
|
||||
|
@ -1360,7 +1372,7 @@ void Vibrator::waitForComplete(std::shared_ptr<IVibratorCallback> &&callback) {
|
|||
|
||||
if (!mHwApi->pollVibeState(VIBE_STATE_HAPTIC,
|
||||
(mSyncedCallback) ? POLLING_TIMEOUT_IN_SYNC : POLLING_TIMEOUT)) {
|
||||
ALOGV("Fail to get state \"Haptic\"");
|
||||
ALOGV("Failed to get state \"Haptic\"");
|
||||
}
|
||||
|
||||
mHwApi->pollVibeState(VIBE_STATE_STOPPED);
|
||||
|
|
|
@ -27,6 +27,18 @@ namespace android {
|
|||
namespace hardware {
|
||||
namespace vibrator {
|
||||
|
||||
const char *kHAPMGRNAME = std::getenv("HAPTIC_MGR_NAME");
|
||||
#undef ALOGV
|
||||
#define ALOGV(...) ((void)ALOG(LOG_VERBOSE, kHAPMGRNAME, __VA_ARGS__))
|
||||
#undef ALOGD
|
||||
#define ALOGD(...) ((void)ALOG(LOG_DEBUG, kHAPMGRNAME, __VA_ARGS__))
|
||||
#undef ALOGI
|
||||
#define ALOGI(...) ((void)ALOG(LOG_INFO, kHAPMGRNAME, __VA_ARGS__))
|
||||
#undef ALOGW
|
||||
#define ALOGW(...) ((void)ALOG(LOG_WARN, kHAPMGRNAME, __VA_ARGS__))
|
||||
#undef ALOGE
|
||||
#define ALOGE(...) ((void)ALOG(LOG_ERROR, kHAPMGRNAME, __VA_ARGS__))
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::binder::Status;
|
||||
using ::android::hardware::vibrator::BnVibratorSyncCallback;
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
on property:vendor.all.modules.ready=1
|
||||
wait /sys/bus/i2c/devices/i2c-cs40l26a-dual/calibration/redc_cal_time_ms
|
||||
|
||||
mkdir /mnt/vendor/persist/haptics 0770 system system
|
||||
chmod 770 /mnt/vendor/persist/haptics
|
||||
chmod 440 /mnt/vendor/persist/haptics/cs40l26_dual.cal
|
||||
chown system system /mnt/vendor/persist/haptics
|
||||
chown system system /mnt/vendor/persist/haptics/cs40l26_dual.cal
|
||||
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/calibration/f0_stored
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/calibration/q_stored
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/calibration/redc_stored
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/vibe_state
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/num_waves
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/f0_offset
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/owt_free_space
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/f0_comp_enable
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/redc_comp_enable
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/delay_before_stop_playback_us
|
||||
|
||||
enable vendor.vibrator.cs40l26-dual
|
||||
|
||||
service vendor.vibrator.cs40l26-dual /vendor/bin/hw/android.hardware.vibrator-service.cs40l26-dual-private
|
||||
class hal
|
||||
user system
|
||||
group system input
|
||||
|
||||
setenv INPUT_EVENT_NAME cs40l26_dual_input
|
||||
setenv INPUT_EVENT_PATH /dev/input/event*
|
||||
setenv PROPERTY_PREFIX ro.vendor.vibrator.hal.
|
||||
setenv CALIBRATION_FILEPATH /mnt/vendor/persist/haptics/cs40l26_dual.cal
|
||||
|
||||
setenv HWAPI_PATH_PREFIX /sys/bus/i2c/devices/i2c-cs40l26a-dual/
|
||||
setenv HWAPI_DEBUG_PATHS "
|
||||
calibration/f0_stored
|
||||
calibration/redc_stored
|
||||
calibration/q_stored
|
||||
default/vibe_state
|
||||
default/num_waves
|
||||
default/f0_offset
|
||||
default/owt_free_space
|
||||
default/f0_comp_enable
|
||||
default/redc_comp_enable
|
||||
default/delay_before_stop_playback_us
|
||||
"
|
||||
|
||||
disabled
|
|
@ -1,7 +0,0 @@
|
|||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.vibrator</name>
|
||||
<version>2</version>
|
||||
<fqname>IVibrator/dual</fqname>
|
||||
</hal>
|
||||
</manifest>
|
|
@ -4,27 +4,41 @@ on property:vendor.all.modules.ready=1
|
|||
mkdir /mnt/vendor/persist/haptics 0770 system system
|
||||
chmod 770 /mnt/vendor/persist/haptics
|
||||
chmod 440 /mnt/vendor/persist/haptics/cs40l26.cal
|
||||
chmod 440 /mnt/vendor/persist/haptics/cs40l26_dual.cal
|
||||
chown system system /mnt/vendor/persist/haptics
|
||||
chown system system /mnt/vendor/persist/haptics/cs40l26.cal
|
||||
chown system system /mnt/vendor/persist/haptics/cs40l26_dual.cal
|
||||
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a/calibration/f0_stored
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/calibration/f0_stored
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a/calibration/q_stored
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/calibration/q_stored
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a/calibration/redc_stored
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/calibration/redc_stored
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/vibe_state
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/vibe_state
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/num_waves
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/num_waves
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/f0_offset
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/f0_offset
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/owt_free_space
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/owt_free_space
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/f0_comp_enable
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/f0_comp_enable
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/redc_comp_enable
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/redc_comp_enable
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a/default/delay_before_stop_playback_us
|
||||
chown system system /sys/bus/i2c/devices/i2c-cs40l26a-dual/default/delay_before_stop_playback_us
|
||||
|
||||
enable vendor.vibrator.cs40l26
|
||||
enable vendor.vibrator.cs40l26-dual
|
||||
|
||||
service vendor.vibrator.cs40l26 /vendor/bin/hw/android.hardware.vibrator-service.cs40l26-private
|
||||
class hal
|
||||
user system
|
||||
group system input
|
||||
|
||||
setenv HAPTIC_NAME HapticsBase
|
||||
setenv INPUT_EVENT_NAME cs40l26_input
|
||||
setenv INPUT_EVENT_PATH /dev/input/event*
|
||||
setenv PROPERTY_PREFIX ro.vendor.vibrator.hal.
|
||||
|
@ -45,3 +59,30 @@ service vendor.vibrator.cs40l26 /vendor/bin/hw/android.hardware.vibrator-service
|
|||
"
|
||||
|
||||
disabled
|
||||
|
||||
service vendor.vibrator.cs40l26-dual /vendor/bin/hw/android.hardware.vibrator-service.cs40l26-private
|
||||
class hal
|
||||
user system
|
||||
group system input
|
||||
|
||||
setenv HAPTIC_NAME HapticsFlip
|
||||
setenv INPUT_EVENT_NAME cs40l26_dual_input
|
||||
setenv INPUT_EVENT_PATH /dev/input/event*
|
||||
setenv PROPERTY_PREFIX ro.vendor.vibrator.hal.
|
||||
setenv CALIBRATION_FILEPATH /mnt/vendor/persist/haptics/cs40l26_dual.cal
|
||||
|
||||
setenv HWAPI_PATH_PREFIX /sys/bus/i2c/devices/i2c-cs40l26a-dual/
|
||||
setenv HWAPI_DEBUG_PATHS "
|
||||
calibration/f0_stored
|
||||
calibration/redc_stored
|
||||
calibration/q_stored
|
||||
default/vibe_state
|
||||
default/num_waves
|
||||
default/f0_offset
|
||||
default/owt_free_space
|
||||
default/f0_comp_enable
|
||||
default/redc_comp_enable
|
||||
default/delay_before_stop_playback_us
|
||||
"
|
||||
|
||||
disabled
|
||||
|
|
|
@ -4,4 +4,9 @@
|
|||
<version>2</version>
|
||||
<fqname>IVibrator/default</fqname>
|
||||
</hal>
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.vibrator</name>
|
||||
<version>2</version>
|
||||
<fqname>IVibrator/dual</fqname>
|
||||
</hal>
|
||||
</manifest>
|
||||
|
|
|
@ -9,6 +9,7 @@ service vendor.vibrator.cs40l26-stereo /vendor/bin/hw/android.hardware.vibrator-
|
|||
user root
|
||||
group root
|
||||
|
||||
setenv HAPTIC_MGR_NAME HapticsMgr
|
||||
setenv PROPERTY_PREFIX ro.vendor.vibrator.hal.
|
||||
|
||||
disabled
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
PRODUCT_PACKAGES += \
|
||||
android.hardware.vibrator-service.cs40l26-private \
|
||||
android.hardware.vibrator-service.cs40l26-dual-private \
|
||||
android.hardware.vibrator-service.cs40l26-stereo-private \
|
||||
android.hardware.vibrator-service.cs40l26-stereo-private
|
||||
|
||||
BOARD_SEPOLICY_DIRS += \
|
||||
device/google/felix-sepolicy/vibrator/common \
|
||||
device/google/felix-sepolicy/vibrator/cs40l26
|
||||
hardware/google/pixel-sepolicy/vibrator/common \
|
||||
hardware/google/pixel-sepolicy/vibrator/cs40l26
|
||||
|
|
|
@ -32,17 +32,23 @@ using ::android::sp;
|
|||
using ::android::String16;
|
||||
using ::android::hardware::vibrator::VibratorSync;
|
||||
|
||||
#if !defined(VIBRATOR_NAME)
|
||||
#define VIBRATOR_NAME "default"
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
const char *inputEventName = std::getenv("INPUT_EVENT_NAME");
|
||||
std::string vibName = "";
|
||||
if (strstr(inputEventName, "cs40l26_input") != nullptr) {
|
||||
vibName.assign("default");
|
||||
} else if (strstr(inputEventName, "cs40l26_dual_input") != nullptr) {
|
||||
vibName.assign("dual");
|
||||
} else {
|
||||
ALOGE("Failed to init vibrator HAL");
|
||||
return EXIT_FAILURE; // should not reach
|
||||
}
|
||||
auto svc = ndk::SharedRefBase::make<Vibrator>(std::make_unique<HwApi>(),
|
||||
std::make_unique<HwCal>());
|
||||
const auto svcName = std::string() + svc->descriptor + "/" + VIBRATOR_NAME;
|
||||
const auto svcName = std::string() + svc->descriptor + "/" + vibName;
|
||||
|
||||
auto ext = sp<VibratorSync>::make(svc);
|
||||
const auto extName = std::stringstream() << ext->descriptor << "/" << VIBRATOR_NAME;
|
||||
const auto extName = std::stringstream() << ext->descriptor << "/" << vibName;
|
||||
|
||||
ProcessState::initWithDriver("/dev/vndbinder");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue