Snap for 12229688 from 4c54ddb36f
to 24Q4-release
Change-Id: I0cf10821a705de242395a9b8dc04dc6878150dac
This commit is contained in:
commit
db8dcec399
2 changed files with 36 additions and 18 deletions
|
@ -58,7 +58,7 @@ static constexpr int8_t MAX_PAUSE_TIMING_ERROR_MS = 1; // ALERT Irq Handling
|
|||
static constexpr uint32_t MAX_TIME_MS = UINT16_MAX;
|
||||
|
||||
static constexpr auto ASYNC_COMPLETION_TIMEOUT = std::chrono::milliseconds(100);
|
||||
static constexpr auto POLLING_TIMEOUT = 20;
|
||||
static constexpr auto POLLING_TIMEOUT = 50;
|
||||
static constexpr int32_t COMPOSE_DELAY_MAX_MS = 10000;
|
||||
|
||||
/* nsections is 8 bits. Need to preserve 1 section for the first delay before the first effect. */
|
||||
|
@ -683,8 +683,21 @@ Vibrator::Vibrator(std::unique_ptr<HwApi> hwApiDefault, std::unique_ptr<HwCal> h
|
|||
mSupportedPrimitives = defaultSupportedPrimitives;
|
||||
}
|
||||
|
||||
mPrimitiveMaxScale = {1.0f, 0.95f, 0.75f, 0.9f, 1.0f, 1.0f, 1.0f, 0.75f, 0.75f};
|
||||
mPrimitiveMinScale = {0.0f, 0.01f, 0.11f, 0.23f, 0.0f, 0.25f, 0.02f, 0.03f, 0.16f};
|
||||
mPrimitiveMaxScale.resize(WAVEFORM_MAX_INDEX, 100);
|
||||
mPrimitiveMaxScale[WAVEFORM_CLICK_INDEX] = 95;
|
||||
mPrimitiveMaxScale[WAVEFORM_THUD_INDEX] = 75;
|
||||
mPrimitiveMaxScale[WAVEFORM_SPIN_INDEX] = 90;
|
||||
mPrimitiveMaxScale[WAVEFORM_LIGHT_TICK_INDEX] = 75;
|
||||
mPrimitiveMaxScale[WAVEFORM_LOW_TICK_INDEX] = 75;
|
||||
|
||||
mPrimitiveMinScale.resize(WAVEFORM_MAX_INDEX, 0);
|
||||
mPrimitiveMinScale[WAVEFORM_CLICK_INDEX] = 1;
|
||||
mPrimitiveMinScale[WAVEFORM_THUD_INDEX] = 11;
|
||||
mPrimitiveMinScale[WAVEFORM_SPIN_INDEX] = 23;
|
||||
mPrimitiveMinScale[WAVEFORM_SLOW_RISE_INDEX] = 25;
|
||||
mPrimitiveMinScale[WAVEFORM_QUICK_FALL_INDEX] = 2;
|
||||
mPrimitiveMinScale[WAVEFORM_LIGHT_TICK_INDEX] = 3;
|
||||
mPrimitiveMinScale[WAVEFORM_LOW_TICK_INDEX] = 16;
|
||||
|
||||
// ====== Get GPIO status and init it ================
|
||||
mGPIOStatus = mHwGPIO->getGPIO();
|
||||
|
@ -908,14 +921,6 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect> &composi
|
|||
if (!status.isOk()) {
|
||||
return status;
|
||||
}
|
||||
// Add a max and min threshold to prevent the device crash(overcurrent) or no
|
||||
// feeling
|
||||
if (effectScale > mPrimitiveMaxScale[static_cast<uint32_t>(e_curr.primitive)]) {
|
||||
effectScale = mPrimitiveMaxScale[static_cast<uint32_t>(e_curr.primitive)];
|
||||
}
|
||||
if (effectScale < mPrimitiveMinScale[static_cast<uint32_t>(e_curr.primitive)]) {
|
||||
effectScale = mPrimitiveMinScale[static_cast<uint32_t>(e_curr.primitive)];
|
||||
}
|
||||
effectVolLevel = intensityToVolLevel(effectScale, effectIndex);
|
||||
}
|
||||
|
||||
|
@ -1417,7 +1422,13 @@ binder_status_t Vibrator::dump(int fd, const char **args, uint32_t numArgs) {
|
|||
}
|
||||
}
|
||||
|
||||
dprintf(fd, "Base: OWT waveform:\n");
|
||||
dprintf(fd, "==== Scales ====\n\tId\tMinScale\tMaxScale\n");
|
||||
for (effectId = 0; effectId < WAVEFORM_MAX_PHYSICAL_INDEX; effectId++) {
|
||||
dprintf(fd, "\t%d\t%d\t\t%d\n", effectId, mPrimitiveMinScale[effectId],
|
||||
mPrimitiveMaxScale[effectId]);
|
||||
}
|
||||
|
||||
dprintf(fd, "\nBase: OWT waveform:\n");
|
||||
dprintf(fd, "\tId\tBytes\tData\tt\ttrigger button\n");
|
||||
for (effectId = WAVEFORM_MAX_PHYSICAL_INDEX; effectId < WAVEFORM_MAX_INDEX; effectId++) {
|
||||
uint32_t numBytes = mFfEffects[effectId].u.periodic.custom_len * 2;
|
||||
|
@ -1525,10 +1536,6 @@ ndk::ScopedAStatus Vibrator::getSimpleDetails(Effect effect, EffectStrength stre
|
|||
case Effect::HEAVY_CLICK:
|
||||
effectIndex = WAVEFORM_CLICK_INDEX;
|
||||
intensity *= 1.0f;
|
||||
// WAVEFORM_CLICK_INDEX is 2, but the primitive CLICK index is 1.
|
||||
if (intensity > mPrimitiveMaxScale[WAVEFORM_CLICK_INDEX - 1]) {
|
||||
intensity = mPrimitiveMaxScale[WAVEFORM_CLICK_INDEX - 1];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
|
@ -1770,6 +1777,17 @@ uint32_t Vibrator::intensityToVolLevel(float intensity, uint32_t effectIndex) {
|
|||
volLevel = calc(intensity, mClickEffectVol);
|
||||
break;
|
||||
}
|
||||
|
||||
// The waveform being played must fall within the allowable scale range
|
||||
if (effectIndex < WAVEFORM_MAX_INDEX) {
|
||||
if (volLevel > mPrimitiveMaxScale[effectIndex]) {
|
||||
volLevel = mPrimitiveMaxScale[effectIndex];
|
||||
}
|
||||
if (volLevel < mPrimitiveMinScale[effectIndex]) {
|
||||
volLevel = mPrimitiveMinScale[effectIndex];
|
||||
}
|
||||
}
|
||||
|
||||
return volLevel;
|
||||
}
|
||||
|
||||
|
|
|
@ -243,8 +243,8 @@ class Vibrator : public BnVibrator {
|
|||
bool mIsChirpEnabled;
|
||||
uint32_t mSupportedPrimitivesBits = 0x0;
|
||||
std::vector<CompositePrimitive> mSupportedPrimitives;
|
||||
std::vector<float> mPrimitiveMaxScale;
|
||||
std::vector<float> mPrimitiveMinScale;
|
||||
std::vector<uint32_t> mPrimitiveMaxScale;
|
||||
std::vector<uint32_t> mPrimitiveMinScale;
|
||||
bool mConfigHapticAlsaDeviceDone{false};
|
||||
bool mGPIOStatus;
|
||||
bool mIsDual{false};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue