Skip to contentSkip to conversation

ForceFeedback sequences

RFC New Jari Vanhala 1 participant 1 message Feb 10, 2010

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

RFC 1/1 ForceFeedback sequences

Linux FF-interface hasn't developed much. How about adding sequences to that interface.

Here is small test-patch which I made to look what kind of problems there might be. This is ff-memless only because I wanted to reuse it's timer system. Also, it's not optimized (kind of ugly hack :). Anyway, it shows some problematic things, like custom_data pointer state, ownership of effect and is effect still enabled. Moving to ff-core solves most of these.

More generic way to do this would be at ff-core, so all ff-devices could use it, but thats not a simple task (timers..). Also kind of misusing custom-field is probably not so good thing :). Maybe adding new type or something.

So, what you think? Does this make any sense?

	++Jam
Quoted 1 line

From dec8a86ff4b287019b4ce6989a738934c9eb95a1 Mon Sep 17 00:00:00 2001

From: Jari Vanhala <[email protected]>
Date: Tue, 9 Feb 2010 11:03:54 +0200
Subject: [PATCH] Input: FF-memless custom sequence hack

This takes unused custom functionality and use it for making sequences in ff-memless. This can be only counted as a hack for testing purposes.

---
 drivers/input/ff-core.c      |    9 +++
 drivers/input/ff-memless.c   |  115 ++++++++++++++++++++++++++++++++++++++++-
 drivers/input/input-compat.c |    1 +
 3 files changed, 122 insertions(+), 3 deletions(-)
drivers/input/ff-core.c +9 -0
index 59797a3..6396328 100644
@@ -193,6 +193,9 @@ static int erase_effect(struct input_dev *dev, int effect_id,
 		return error;
 
 	spin_lock_irq(&dev->event_lock);
+	if (ff->effects[effect_id].type == FF_PERIODIC &&
+	    ff->effects[effect_id].u.periodic.waveform == FF_CUSTOM)
+		ff->effects[effect_id].u.periodic.custom_data = NULL;
 	ff->playback(dev, effect_id, 0);
 	ff->effect_owners[effect_id] = NULL;
 	spin_unlock_irq(&dev->event_lock);
@@ -250,6 +253,12 @@ static int flush_effects(struct input_dev *dev, struct file *file)
 	mutex_lock(&ff->mutex);
 
 	for (i = 0; i < ff->max_effects; i++)
+		if (!check_effect_access(ff, i, file) &&
+		    ff->effects[i].type == FF_PERIODIC &&
+		    ff->effects[i].u.periodic.waveform == FF_CUSTOM)
+			ff->effects[i].u.periodic.custom_data = NULL;
+
+	for (i = 0; i < ff->max_effects; i++)
 		erase_effect(dev, i, file);
 
 	mutex_unlock(&ff->mutex);
drivers/input/ff-memless.c +112 -3

160 lines not on this page · raw message

drivers/input/input-compat.c +1 -0
index 1accb89..2df00b6 100644
@@ -83,6 +83,7 @@ int input_ff_effect_from_user(const char __user *buffer, size_t size,
 
 		if (compat_effect->type == FF_PERIODIC &&
 		    compat_effect->u.periodic.waveform == FF_CUSTOM)
+			/* This propably should make a real copy ++Jam */
 			effect->u.periodic.custom_data =
 				compat_ptr(compat_effect->u.periodic.custom_data);
 	} else {
Signature · 1 line
1.6.3.3