[PATCH v3 2/4] input: ff-memless: Handle FF_TRIGGER_RUMBLE

Guillaume Casal <[email protected]> Fri, 31 Jul 2026 07:41:57 +0200
Newsgroups org.kernel.vger.linux-input,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Combine trigger rumble effects the way the other types are combined, so
that drivers using input_ff_create_memless() receive them.

Because ml_get_combo_effect() groups playing effects by type, a trigger
rumble effect forms its own combo and reaches the driver in its own
play_effect() call, leaving FF_RUMBLE untouched. An effect that has
finished still contributes its type to the combo with zero magnitudes,
so the existing stop path works unchanged.

Signed-off-by: Guillaume Casal <[email protected]>
---
diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c
--- a/drivers/input/ff-memless.c
+++ b/drivers/input/ff-memless.c
@@ -289,6 +289,15 @@
 			min(weak + effect->u.rumble.weak_magnitude, 0xffffU);
 		break;
 
+	case FF_TRIGGER_RUMBLE:
+		effect->u.trigger_rumble.left_magnitude =
+			min((u32)new->u.trigger_rumble.left_magnitude * gain / 0xffff +
+			    effect->u.trigger_rumble.left_magnitude, 0xffffU);
+		effect->u.trigger_rumble.right_magnitude =
+			min((u32)new->u.trigger_rumble.right_magnitude * gain / 0xffff +
+			    effect->u.trigger_rumble.right_magnitude, 0xffffU);
+		break;
+
 	case FF_PERIODIC:
 		i = apply_envelope(state, abs(new->u.periodic.magnitude),
 				   &new->u.periodic.envelope);