提交 8c374ef4 编写于 作者: C Charles Keepax 提交者: Dmitry Torokhov

Input: ff-core - correct magnitude setting for rumble compatibility

When converting a rumble into a periodic effect, for compatibility,
the magnitude is effectively calculated using:

magnitude = max(strong_rubble / 3 + weak_rubble / 6, 0x7fff);

The rumble magnitudes are both u16 and the resulting magnitude is
s16. The max is presumably an attempt to limit the result of the
calculation to the maximum possible magnitude for the s16 result,
and thus should be a min.

However in the case of strong = weak = 0xffff, the result of the first
part of the calculation is 0x7fff, meaning that the min would be
redundant anyway, so simply remove the current max.
Signed-off-by: NCharles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20211130135039.13726-1-ckeepax@opensource.cirrus.comSigned-off-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
上级 b85a4d96
...@@ -67,7 +67,7 @@ static int compat_effect(struct ff_device *ff, struct ff_effect *effect) ...@@ -67,7 +67,7 @@ static int compat_effect(struct ff_device *ff, struct ff_effect *effect)
effect->type = FF_PERIODIC; effect->type = FF_PERIODIC;
effect->u.periodic.waveform = FF_SINE; effect->u.periodic.waveform = FF_SINE;
effect->u.periodic.period = 50; effect->u.periodic.period = 50;
effect->u.periodic.magnitude = max(magnitude, 0x7fff); effect->u.periodic.magnitude = magnitude;
effect->u.periodic.offset = 0; effect->u.periodic.offset = 0;
effect->u.periodic.phase = 0; effect->u.periodic.phase = 0;
effect->u.periodic.envelope.attack_length = 0; effect->u.periodic.envelope.attack_length = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册