* [PATCH] Input: ff-core - Correct magnitude setting for rumble compatibility
@ 2021-11-30 13:50 Charles Keepax
2021-12-07 7:23 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Charles Keepax @ 2021-11-30 13:50 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: linux-input, patches, linux-kernel
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: Charles Keepax <ckeepax@opensource.cirrus.com>
---
drivers/input/ff-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/ff-core.c b/drivers/input/ff-core.c
index 1cf5deda06e19..fa8d1a4660142 100644
--- a/drivers/input/ff-core.c
+++ b/drivers/input/ff-core.c
@@ -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;
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: ff-core - Correct magnitude setting for rumble compatibility
2021-11-30 13:50 [PATCH] Input: ff-core - Correct magnitude setting for rumble compatibility Charles Keepax
@ 2021-12-07 7:23 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2021-12-07 7:23 UTC (permalink / raw)
To: Charles Keepax; +Cc: linux-input, patches, linux-kernel
On Tue, Nov 30, 2021 at 01:50:39PM +0000, Charles Keepax wrote:
> 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: Charles Keepax <ckeepax@opensource.cirrus.com>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-07 7:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-30 13:50 [PATCH] Input: ff-core - Correct magnitude setting for rumble compatibility Charles Keepax
2021-12-07 7:23 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).