Skip to contentSkip to conversation

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

PATCH Applied Charles Keepax 2 participants 2 messages Nov 30, 2021 – Dec 7, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/input/ff-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/ff-core.c +1 -1
index 1cf5deda06e19..fa8d1a4660142 100644
@@ -67,7 +67,7 @@ static int compat_effect(struct ff_device *ff, struct ff_effect *effect)
 		effect->type = FF_PERIODIC;
 		effect->u.periodic.waveform = FF_SINE;
 		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.phase = 0;
 		effect->u.periodic.envelope.attack_length = 0;
Signature · 1 line
2.11.0
maintainer Applied
#1 lore raw
Quoted 10 lines · Charles Keepax

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.

Quoted 5 lines

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.

Applied, thank you.

Signature · 1 line
Dmitry