[DO NOT MERGE] vibrator/cs40l26: Adding minimum scale for composition primitives am: 6346fec3af

Original change: https://googleplex-android-review.googlesource.com/c/device/google/felix/+/20731907

Change-Id: I6ddf36a2b5032f4e7f8b33ea3928224587a1315e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Nathan Kulczak 2022-12-22 09:39:35 +00:00 committed by Automerger Merge Worker
commit 914a06bc51
2 changed files with 10 additions and 2 deletions

View file

@ -529,6 +529,8 @@ Vibrator::Vibrator(std::unique_ptr<HwApi> hwApiDefault, std::unique_ptr<HwCal> h
mSupportedPrimitives = defaultSupportedPrimitives;
}
mPrimitiveMinScale = {0.0f, 0.01f, 0.11f, 0.23f, 0.0f, 0.25f, 0.02f, 0.03f, 0.16f};
// ====== Get GPIO status and init it ================
mGPIOStatus = mHwGPIO->getGPIO();
if (!mGPIOStatus || !mHwGPIO->initGPIO()) {
@ -758,17 +760,22 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect> &composi
auto &e_curr = composite[i_curr];
uint32_t effectIndex = 0;
uint32_t effectVolLevel = 0;
if (e_curr.scale < 0.0f || e_curr.scale > 1.0f) {
float effectScale = e_curr.scale;
if (effectScale < 0.0f || effectScale > 1.0f) {
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
if(effectScale < mPrimitiveMinScale[static_cast<uint32_t>(e_curr.primitive)]) {
effectScale = mPrimitiveMinScale[static_cast<uint32_t>(e_curr.primitive)];
}
if (e_curr.primitive != CompositePrimitive::NOOP) {
ndk::ScopedAStatus status;
status = getPrimitiveDetails(e_curr.primitive, &effectIndex);
if (!status.isOk()) {
return status;
}
effectVolLevel = intensityToVolLevel(e_curr.scale, effectIndex);
effectVolLevel = intensityToVolLevel(effectScale, effectIndex);
totalDuration += mEffectDurations[effectIndex];
}

View file

@ -231,6 +231,7 @@ class Vibrator : public BnVibrator {
bool mIsChirpEnabled;
uint32_t mSupportedPrimitivesBits = 0x0;
std::vector<CompositePrimitive> mSupportedPrimitives;
std::vector<float> mPrimitiveMinScale;
bool mConfigHapticAlsaDeviceDone{false};
bool mGPIOStatus;
bool mIsDual{false};