Skip to contentSkip to conversation

Add ff-memless-next and make hid-lg4ff use it

PATCH In review Michal Malý 4 participants 15 messages Feb 23, 2014 – Feb 24, 2014

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

v2 cover Add ff-memless-next and make hid-lg4ff use it

Hi everybody,

this patch series is a result of my work to improve FFB support for memoryless devices. ff-memless-next is an improvement over the currently available ff-memless which is well suited for joypads but cannot handle more advanced devices such as racing wheels properly. As I have explained in one of RFCs regarding ff-memless-next, the extent of the changes makes implementing ff-memless-next as a patch to ff-memless unfeasible. As of now there is a total of 27 drivers using ff-memless (including lg4ff) - a lot of them joypads. I do not have access to any FFB joypad at the moment so I cannot implement the functionality required to handle joypads properly - namely FF_RUMBLE and emulation of FF_PERIODIC through FF_RUMBLE.
The plan is to implement the missing functionality and replace ff-memless completely in the future.

Second part of this series ports lg4ff driver over to ff-memless-next. The immediate benefit of this is support of all periodic effects and ramp effect.

v2 addresses a few issues that have not been noticed at the time v1 was submitted. Specific fixes are mentioned in the respective patches.

Michal M.

Michal Malý (4):
INPUT: Add ff-memless-next module
HID: Port hid-lg4ff to ff-memless-next
HID: Add support for periodic effects in hid-lg4ff
HID: Add support for ramp effect in hid-lg4ff

 Documentation/input/ff-memless-next.txt | 141 ++++++
 drivers/hid/Kconfig                     |   2 +-
 drivers/hid/hid-lg4ff.c                 |  93 ++--
 drivers/input/Kconfig                   |  11 +
 drivers/input/Makefile                  |   1 +
 drivers/input/ff-memless-next.c         | 789 ++++++++++++++++++++++++++++++++
 include/linux/input/ff-memless-next.h   |  32 ++
 7 files changed, 1033 insertions(+), 36 deletions(-)

--
1.9.0

--
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw

PATCH v2 1/4 Add ff-memless-next driver

Introduce ff-memless-next module as a possible future replacement of ff-memless.

---
v2:
Handle upload and removal of uncombinable effects correctly Remove redundant information from the documentation file Invert direction of force along Y axis to conform to common conventions Set FF_GAIN bit

 Documentation/input/ff-memless-next.txt | 141 ++++++
 drivers/input/Kconfig                   |  11 +
 drivers/input/Makefile                  |   1 +
 drivers/input/ff-memless-next.c         | 789 ++++++++++++++++++++++++++++++++
 include/linux/input/ff-memless-next.h   |  32 ++
 5 files changed, 974 insertions(+)
 create mode 100644 Documentation/input/ff-memless-next.txt
 create mode 100644 drivers/input/ff-memless-next.c
 create mode 100644 include/linux/input/ff-memless-next.h
Documentation/input/ff-memless-next.txt new file +141 -0
new file mode 100644
index 0000000..1b550dc
@@ -0,0 +1,141 @@
+"ff-memless-next" force feedback module for memoryless devices.
+By Michal Malý <[email protected]> on 2013/12/21
+----------------------------------------------------------------------------
+
+1. Introduction
+~~~~~~~~~~~~~~~
+This document describes basic working principles of the "ff-memless-next"
+module and its purpose. This document also contains a summary
+of the "ff-memless-next" API and brief instructions on how to use it to write
+a hardware-specific backend with "ff-memless-next". Some specifics
+of ff-memless-next that might be of interest for userspace developers
+are also discussed.
+
+2. Basic principles of ff-memless-next
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+A lot of commonly used force feedback devices do not have a memory of their
+own. This means that it is not possible to upload a force feedback effect
+to such a device and let the device's CPU handle the playback. Instead,
+the device relies solely on its driver to tell it what force to generate.
+"ff-memless-next" was written to serve in this capacity. Its purpose is to
+calculate the overall force the device should apply and pass the result to
+a hardware-specific backend which then submits the appropriate command to
+the device.
+
+"ff-memless-next" differentiates between two types of force feedback effects,
+"combinable" and "uncombinable".
+"Combinable" effects are effects that generate a force of a given
+magnitude and direction. The magnitude can change in time according to the
+envelope of the effect and its waveform; the latter applies only to periodic
+effects. Force generated by "combinable" effect does not depend on the position
+of the device. Forces generated by each "combinable" effect that is active
+are periodically recalculated as needed and superposed into one overall force.
+"Combinable" effects are FF_CONSTANT, FF_PERIODIC and FF_RAMP.
+
+"Uncombinable" effects generate a force that depends on the position of
+the device. "ff-memless-next" assumes that the device takes care of processing
+such an effect. However, a device might have a limit on how many "uncombinable"
+effects can be active at once and this limit might be lower than the maximum
+effect count set in "ff-memless-next". "ff-memless-next" allows a
+hardware-specific driver to check whether the device is able to play
+an "uncombinable" effect. As of now an error during effect upload is not
+reported back to userspace. Please be prepared that this might change
+in the future.
+"Uncombinable" effects are FF_DAMPER, FF_FRICTION, FF_INERTIA and FF_SPRING.
+
+FF_CUSTOM is currently not handled by "ff-memless-next".
+
+3. API provided by "ff-memless-next"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+"ff-memless-next" provides an API for developers of hardware-specific
+drivers. In order to use the API, the hardware-specific driver should
+include <linux/input/ff-memless-next.h>
+Functions and structs defined by this API are:
+
+int input_ff_create_mlnx(struct input_dev *dev, void *data,
+			 int(*control_effect)(struct input_dev *, void *, const struct mlnx_effect_command *),
+			 const u16 update_rate)
+- Any hardware-specific driver that wants to use "ff-memless-next" must call
+this function. The function takes care of creating and registering a force
+feedback device within the kernel. It also initializes resources needed by
+"ff-memless-next" to handle a new device. No other initialization steps are necessary.
+	Parameters:
+	* dev - pointer to valid struct input_dev
+	* data - pointer to custom data the hardware-specific backend
+		 might need to pass to the control_effect() callback function
+		 (discussed later). * data will be freed automatically by
+		 "ff-memless-next" upon device's destruction.
+	* control_effect - A callback function. "ff-memless-next" will call
+			   this function when it is done processing effects.
+			   Implementation of control_effect() in the
+			   hardware-specific driver should create an appropriate
+			   command and submit it to the device.
+			   This function is called with dev->event_lock
+			   spinlock held.
+	update_rate - Rate in milliseconds at which envelopes and periodic
+		      effects are recalculated. Minimum value is limited by the
+		      kernel timer resolution and changes with value of
+		      CONFIG_HZ.
+
+struct mlnx_effect_command
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+- This struct is passed to the hardware-specific backend in
+the control_effect() function. See "ff-memless-next.h" for details.
+
+enum mlnx_commands
+^^^^^^^^^^^^^^^^^^
+- Types of commands generated by ff-memless-next
+	MLNX_START_COMBINED - Start or update "combinable" effect
+	MLNX_STOP_COMBINED - Stop "combinable" effect. In most cases this means
+			     to set the force to zero.
+	MLNX_UPLOAD_UNCOMB - Check if the device can accept and play
+			     "uncombinable" effect and upload the effect into
+			     the device's internal memory.
+			     Hardware-specific driver should return 0
+			     on success.
+	MLNX_ERASE_UNCOMB - Remove "uncombinable" effect from device's
+			    internal memory.
+			    Hardware-specific driver should return 0
+			    on success.
+	MLNX_START_UNCOMB - Start playback of "uncombinable" effect.
+	MLNX_STOP_UNCOMB - Stop playback of "uncombinable" effect.
+
+struct mlnx_simple_force
+^^^^^^^^^^^^^^^^^^^^^^^^
+	x - overall force along X axis
+	y - overall force along Y axis
+
+struct mlnx_uncomb_effect
+^^^^^^^^^^^^^^^^^^^^^^^^^
+- Information about "uncombinable" effect.
+	id - internal ID of the effect
+	* effect - pointer to the internal copy of the effect kept by
+		   "ff-memless-next". This pointer will remain valid until
+		   the effect is removed.
+
+Sample implementation of a dummy driver that uses "ff-memless-next" is
+available at "git://prifuk.cz/ff-dummy-device". Link to the source will
+be kept up to date.
+
+4. Specifics of "ff-memless-next" for userspace developers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+None of the persons involved in development or testing of "ff-memless-next"
+is aware of any reference force feedback specifications. "ff-memless-next"
+tries to adhere to Microsoft's DirectInput specifications because we
+believe that is what most developers have experience with.
+
+- Waveforms of periodic effects do not start at the origin, but as follows:
+	SAW_UP: At minimum
+	SAW_DOWN: At maximum
+	SQUARE: At maximum
+	TRIANGLE: At maximum
+	SINE: At origin
+
+- Updating periodic effects:
+	- All periodic effects are restarted when their parameters are updated.
+
+- Updating effects of finite duration:
+	- Once an effect of finite length finishes playing, it is considered
+	  stopped. Only effects that are playing can be updated on the fly.
+	  Therefore effects of finite duration can be updated only until
+	  they finish playing.
drivers/input/Kconfig +11 -0
index a11ff74..ba05100 100644
@@ -77,6 +77,17 @@ config INPUT_MATRIXKMAP
 	  To compile this driver as a module, choose M here: the
 	  module will be called matrix-keymap.
 
+config INPUT_FF_MEMLESS_NEXT
+	tristate "New version of support for memoryless force feedback devices"
+	help
+	  Say Y here if you want to enable support for various memoryless
+	  force feedback devices.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ff-memless-next.
+
 comment "Userland interfaces"
 
 config INPUT_MOUSEDEV
drivers/input/Makefile +1 -0
index 5ca3f63..169e99c 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_INPUT_FF_MEMLESS)	+= ff-memless.o
 obj-$(CONFIG_INPUT_POLLDEV)	+= input-polldev.o
 obj-$(CONFIG_INPUT_SPARSEKMAP)	+= sparse-keymap.o
 obj-$(CONFIG_INPUT_MATRIXKMAP)	+= matrix-keymap.o
+obj-$(CONFIG_INPUT_FF_MEMLESS_NEXT)	+= ff-memless-next.o
 
 obj-$(CONFIG_INPUT_MOUSEDEV)	+= mousedev.o
 obj-$(CONFIG_INPUT_JOYDEV)	+= joydev.o
drivers/input/ff-memless-next.c new file +789 -0

789 lines not on this page · raw message

include/linux/input/ff-memless-next.h new file +32 -0
new file mode 100644
index 0000000..ba89ba1
@@ -0,0 +1,32 @@
+#include <linux/input.h>
+
+enum mlnx_commands {
+	MLNX_START_COMBINED,
+	MLNX_STOP_COMBINED,
+	MLNX_START_UNCOMB,
+	MLNX_STOP_UNCOMB,
+	MLNX_UPLOAD_UNCOMB,
+	MLNX_ERASE_UNCOMB
+};
+
+struct mlnx_simple_force {
+	const s32 x;
+	const s32 y;
+};
+
+struct mlnx_uncomb_effect {
+	const int id;
+	const struct ff_effect *effect;
+};
+
+struct mlnx_effect_command {
+	const enum mlnx_commands cmd;
+	union {
+		const struct mlnx_simple_force simple_force;
+		const struct mlnx_uncomb_effect uncomb;
+	} u;
+};
+
+int input_ff_create_mlnx(struct input_dev *dev, void *data,
+			 int(*control_effect)(struct input_dev *, void *, const struct mlnx_effect_command *),
+			 const u16 update_rate);
Signature · 7 lines
1.9.0


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#7 lore raw

PATCH v2 2/4 Port hid-lg4ff to ff-memless-next

In reply to Michal Malý

Port hid-lg4ff to ff-memless-next

---
v2: Differentiate between "set force to zero" and "stop force completely"

 drivers/hid/Kconfig     |  2 +-
 drivers/hid/hid-lg4ff.c | 86 +++++++++++++++++++++++++++++--------------------
 2 files changed, 52 insertions(+), 36 deletions(-)
drivers/hid/Kconfig +1 -1
index f722001..11ac17e 100644
@@ -390,7 +390,7 @@ config LOGIG940_FF
 config LOGIWHEELS_FF
 	bool "Logitech wheels configuration and force feedback support"
 	depends on HID_LOGITECH
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	default LOGITECH_FF
 	help
 	  Say Y here if you want to enable force feedback and range setting
drivers/hid/hid-lg4ff.c +51 -35

117 lines not on this page · raw message

Signature · 7 lines
1.9.0


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

PATCH v2 3/4 hid-lg4ff: Add support for periodic effects

In reply to Michal Malý

hid-lg4ff: Add support for periodic effects

---
 drivers/hid/hid-lg4ff.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/hid/hid-lg4ff.c +6 -0
index 95d2a9f..d7d8d83 100644
@@ -71,6 +71,12 @@ struct lg4ff_device_entry {
 
 static const signed short lg4ff_wheel_effects[] = {
 	FF_CONSTANT,
+	FF_PERIODIC,
+	FF_SQUARE,
+	FF_TRIANGLE,
+	FF_SINE,
+	FF_SAW_UP,
+	FF_SAW_DOWN,
 	FF_AUTOCENTER,
 	-1
 };
Signature · 7 lines
1.9.0


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

PATCH v2 4/4 hid-lg4ff: Add support for ramp effect

In reply to Michal Malý

hid-lg4ff: Add support for ramp effect

---
 drivers/hid/hid-lg4ff.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hid/hid-lg4ff.c +1 -0
index d7d8d83..e5c90bb 100644
@@ -71,6 +71,7 @@ struct lg4ff_device_entry {
 
 static const signed short lg4ff_wheel_effects[] = {
 	FF_CONSTANT,
+	FF_RAMP,
 	FF_PERIODIC,
 	FF_SQUARE,
 	FF_TRIANGLE,
Signature · 7 lines
1.9.0


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Re: [PATCH v2 1/4] Add ff-memless-next driver

In reply to Michal Malý

24.02.2014 01:29, Michal Malý kirjoitti:

Quoted 5 lines

Introduce ff-memless-next module as a possible future replacement of ff-memless.

Some comments below.

Quoted 23 lines

---
v2:
Handle upload and removal of uncombinable effects correctly Remove redundant information from the documentation file Invert direction of force along Y axis to conform to common conventions Set FF_GAIN bit

 Documentation/input/ff-memless-next.txt | 141 ++++++
 drivers/input/Kconfig                   |  11 +
 drivers/input/Makefile                  |   1 +
 drivers/input/ff-memless-next.c         | 789 ++++++++++++++++++++++++++++++++
 include/linux/input/ff-memless-next.h   |  32 ++
 5 files changed, 974 insertions(+)
 create mode 100644 Documentation/input/ff-memless-next.txt
 create mode 100644 drivers/input/ff-memless-next.c
 create mode 100644 include/linux/input/ff-memless-next.h
Documentation/input/ff-memless-next.txt new file +0 -0
new file mode 100644
index 0000000..1b550dc
@@ -0,0 +1,141 @@

[...]

Documentation/input/ff-memless-next.txt line 53

Quoted 6 lines

+3. API provided by "ff-memless-next"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+"ff-memless-next" provides an API for developers of hardware-specific

Documentation/input/ff-memless-next.txt new file +3 -0
+drivers. In order to use the API, the hardware-specific driver should
+include <linux/input/ff-memless-next.h>
+Functions and structs defined by this API are:

[...]

This kind of basic API documentation belongs in the headers (kernel-doc format).

[...]

Documentation/input/ff-memless-next.txt line 101

Quoted 11 lines
Documentation/input/ff-memless-next.txt new file +11 -0
+	MLNX_UPLOAD_UNCOMB - Check if the device can accept and play
+			     "uncombinable" effect and upload the effect into
+			     the device's internal memory.
+			     Hardware-specific driver should return 0
+			     on success.
+	MLNX_ERASE_UNCOMB - Remove "uncombinable" effect from device's
+			    internal memory.
+			    Hardware-specific driver should return 0
+			    on success.
+	MLNX_START_UNCOMB - Start playback of "uncombinable" effect.
+	MLNX_STOP_UNCOMB - Stop playback of "uncombinable" effect.

These seem to be unused by any drivers?

I don't think they should be added to the kernel before there is an implementation using them (it also makes reviewing them more difficult).

[...]

Quoted 12 lines

+4. Specifics of "ff-memless-next" for userspace developers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Documentation/input/ff-memless-next.txt new file +10 -0
+None of the persons involved in development or testing of "ff-memless-next"
+is aware of any reference force feedback specifications. "ff-memless-next"
+tries to adhere to Microsoft's DirectInput specifications because we
+believe that is what most developers have experience with.
+
+- Waveforms of periodic effects do not start at the origin, but as follows:
+	SAW_UP: At minimum
+	SAW_DOWN: At maximum
+	SQUARE: At maximum
+	TRIANGLE: At maximum

Documentation/input/ff-memless-next.txt line 141

Quoted 10 lines
Documentation/input/ff-memless-next.txt new file +10 -0
+	SINE: At origin
+
+- Updating periodic effects:
+	- All periodic effects are restarted when their parameters are updated.
+
+- Updating effects of finite duration:
+	- Once an effect of finite length finishes playing, it is considered
+	  stopped. Only effects that are playing can be updated on the fly.
+	  Therefore effects of finite duration can be updated only until
+	  they finish playing.

Stopped effects should still be able to be updated.

Anyway, if you want to target userspace developers with this information, you should put it in generic documentation ("it is not guaranteed that X", etc.). If not, don't say "for userspace developers".

[...]

Quoted 16 lines
drivers/input/ff-memless-next.c new file +10 -0
new file mode 100644
index 0000000..843a223
@@ -0,0 +1,789 @@
+/*
+ * Force feedback support for memoryless devices
+ *
+ * This module is based on "ff-memless" orignally written by Anssi Hannula.
+ * It is extended to support all force feedback effects currently supported
+ * by the Linux input stack.
+ *
+ * Copyright(c) 2013 Michal Maly <[email protected]>
+ *
+ */

[...]

Quoted 3 lines
drivers/input/ff-memless-next.c new file +3 -0
+static int mlnx_upload(struct input_dev *dev, struct ff_effect *effect,
+		       struct ff_effect *old)
+{

[...]

drivers/input/ff-memless-next.c line 746

Quoted 5 lines
drivers/input/ff-memless-next.c new file +5 -0
+		}
+
+		mlnx_schedule_playback(mlnxdev);
+		spin_unlock_irq(&dev->event_lock);
+		return 0;

The above two lines are unneeded.

Quoted 7 lines
drivers/input/ff-memless-next.c new file +7 -0
+	}
+
+	spin_unlock_irq(&dev->event_lock);
+
+	return 0;
+}
+

[...]

Quoted 6 lines
include/linux/input/ff-memless-next.h new file +0 -0
new file mode 100644
index 0000000..ba89ba1
@@ -0,0 +1,32 @@

[...]

include/linux/input/ff-memless-next.h line 32

Quoted 3 lines
include/linux/input/ff-memless-next.h new file +3 -0
+int input_ff_create_mlnx(struct input_dev *dev, void *data,
+			 int(*control_effect)(struct input_dev *, void *, const struct mlnx_effect_command *),
+			 const u16 update_rate);

Why is update_rate now driver-selectable?

Signature · 6 lines
Anssi Hannula

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw
In reply to Michal Malý

24.02.2014 01:24, Michal Malý kirjoitti:

Quoted 1 line

Hi everybody,

Hi,

Quoted 4 lines

this patch series is a result of my work to improve FFB support for memoryless devices. ff-memless-next is an improvement over the currently available ff-memless which is well suited for joypads but cannot handle more advanced devices such as racing wheels properly. As I have explained in one of RFCs

Quoted 8 lines

regarding ff-memless-next, the extent of the changes makes implementing ff-memless-next as a patch to ff-memless unfeasible. As of now there is a total of 27 drivers using ff-memless (including lg4ff) - a lot of them joypads. I do not have access to any FFB joypad at the moment so I cannot implement the functionality required to handle joypads properly - namely FF_RUMBLE and emulation of FF_PERIODIC through FF_RUMBLE.
The plan is to implement the missing functionality and replace ff-memless completely in the future.

I think we should extend the current ff-memless instead of duplicating its functionality (even on a "for now" basis).

Having looked at ff-memless-next briefly, it seems very similar to ff-memless on its basic working principle, and therefore I don't really see why extending ff-memless would be too cumbersome. Unless I'm missing something - in that case, feel free to point it out to me :)

Duplicating the module makes reviewing it somewhat difficult since the changes are not clearly visible.

As for the amount of drivers using ff-memless, those are ~all very simple (single function call registering a single callback) so it should be easy to apply any API conversion if needed.
And I don't see a real need for you to have access to a rumble joypad - that support is already implemented in ff-memless, and other people can test that it isn't broken by your changes.

Regardless, thanks for looking into this.

Quoted 28 lines

Second part of this series ports lg4ff driver over to ff-memless-next. The immediate benefit of this is support of all periodic effects and ramp effect.

v2 addresses a few issues that have not been noticed at the time v1 was submitted. Specific fixes are mentioned in the respective patches.

Michal M.

Michal Malý (4):
INPUT: Add ff-memless-next module
HID: Port hid-lg4ff to ff-memless-next
HID: Add support for periodic effects in hid-lg4ff
HID: Add support for ramp effect in hid-lg4ff

 Documentation/input/ff-memless-next.txt | 141 ++++++
 drivers/hid/Kconfig                     |   2 +-
 drivers/hid/hid-lg4ff.c                 |  93 ++--
 drivers/input/Kconfig                   |  11 +
 drivers/input/Makefile                  |   1 +
 drivers/input/ff-memless-next.c         | 789 ++++++++++++++++++++++++++++++++
 include/linux/input/ff-memless-next.h   |  32 ++
 7 files changed, 1033 insertions(+), 36 deletions(-)

--
1.9.0

--

Signature · 5 lines
Anssi Hannula
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw
Quoted 19 lines · On Monday 24 of February 2014 02:32:27 Anssi Hannula wrote:

24.02.2014 01:24, Michal Malý kirjoitti:

Quoted 1 line

Hi everybody,

Hi,

Quoted 5 lines

this patch series is a result of my work to improve FFB support for memoryless devices. ff-memless-next is an improvement over the currently available ff-memless which is well suited for joypads but cannot handle more advanced devices such as racing wheels properly. As I have explained in one of RFCs regarding ff-memless-next, the extent of the changes makes

Quoted 8 lines

implementing ff-memless-next as a patch to ff-memless unfeasible. As of now there is a total of 27 drivers using ff-memless (including lg4ff) - a lot of them joypads. I do not have access to any FFB joypad at the moment so I cannot
implement the functionality required to handle joypads properly - namely FF_RUMBLE and emulation of FF_PERIODIC through FF_RUMBLE.
The plan is to implement the missing functionality and replace ff-memless completely in the future.

Quoted 7 lines

I think we should extend the current ff-memless instead of duplicating its functionality (even on a "for now" basis).

Having looked at ff-memless-next briefly, it seems very similar to ff-memless on its basic working principle, and therefore I don't really see why extending ff-memless would be too cumbersome. Unless I'm missing something - in that case, feel free to point it out to me :)

Deciding whether to patch ff-memless or write a new driver from scratch was a perfect example of being caught between the rock and a hard place. I am not particularly fond of the fact that we would have two modules doing pretty much the same thing. My reasons for writing a separate module were:
- Periodic effects. ff-memless doesn't do "real" periodic effects, it simply emulates them through rumble effect. Devices without rumble effect support require emulation through constant force effect. Just this was not something one could write in one afternoon:)
- Conditional effects. These effects cannot be by nature combined into one overall force (at least not easily) so they have to be handled one by one - this is a concept ff-memless does not seem to consider. FFB devices have limits as to how many conditional (referred to as "uncombinable" in MLNX) effects can be active simultaneously, etc.
All in all it seemed less error prone to write a new driver based on the ff- memless logic, test and deploy it on devices I have access to and once we are sure there are no nasty regressions port the rest of the drivers to the new API. Given the scope of the changes I am afraid that a "patch" to ff-memless would be pretty close to a rewrite anyway.

Quoted 9 lines

Duplicating the module makes reviewing it somewhat difficult since the changes are not clearly visible.

As for the amount of drivers using ff-memless, those are ~all very simple (single function call registering a single callback) so it should be easy to apply any API conversion if needed.
And I don't see a real need for you to have access to a rumble joypad - that support is already implemented in ff-memless, and other people can test that it isn't broken by your changes.

It has been my intention to add handling of rumble effects in a followup patch. I wanted to limit the extent of changes I dump in a one massive patch, especially when I cannot test the rumble effect on a real hardware.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

Re: [PATCH v2 1/4] Add ff-memless-next driver

In reply to Anssi Hannula
Quoted 65 lines · On Monday 24 of February 2014 02:32:29 Anssi Hannula wrote:

24.02.2014 01:29, Michal Malý kirjoitti:

Quoted 5 lines

Introduce ff-memless-next module as a possible future replacement of ff-memless.

Some comments below.

Quoted 25 lines

---

v2:
Handle upload and removal of uncombinable effects correctly Remove redundant information from the documentation file Invert direction of force along Y axis to conform to common conventions Set FF_GAIN bit

 Documentation/input/ff-memless-next.txt | 141 ++++++
 drivers/input/Kconfig                   |  11 +
 drivers/input/Makefile                  |   1 +
 drivers/input/ff-memless-next.c         | 789
 ++++++++++++++++++++++++++++++++ include/linux/input/ff-memless-next.h  
 |  32 ++
 5 files changed, 974 insertions(+)
 create mode 100644 Documentation/input/ff-memless-next.txt
 create mode 100644 drivers/input/ff-memless-next.c
 create mode 100644 include/linux/input/ff-memless-next.h
(quoted diff) +0 -0

b/Documentation/input/ff-memless-next.txt new file mode 100644 index 0000000..1b550dc

Documentation/input/ff-memless-next.txt new file +0 -0
@@ -0,0 +1,141 @@

[...]

Documentation/input/ff-memless-next.txt line 53

Quoted 7 lines

+3. API provided by "ff-memless-next"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+"ff-memless-next" provides an API for developers of hardware-specific

Documentation/input/ff-memless-next.txt new file +3 -0
+drivers. In order to use the API, the hardware-specific driver should
+include <linux/input/ff-memless-next.h>
 
+Functions and structs defined by this API are:

[...]

This kind of basic API documentation belongs in the headers (kernel-doc format).

[...]

Documentation/input/ff-memless-next.txt line 101

Quoted 11 lines
Documentation/input/ff-memless-next.txt new file +11 -0
+	MLNX_UPLOAD_UNCOMB - Check if the device can accept and play
+			     "uncombinable" effect and upload the effect into
+			     the device's internal memory.
+			     Hardware-specific driver should return 0
+			     on success.
+	MLNX_ERASE_UNCOMB - Remove "uncombinable" effect from device's
+			    internal memory.
+			    Hardware-specific driver should return 0
+			    on success.
+	MLNX_START_UNCOMB - Start playback of "uncombinable" effect.
+	MLNX_STOP_UNCOMB - Stop playback of "uncombinable" effect.

These seem to be unused by any drivers?

Quoted 2 lines

I don't think they should be added to the kernel before there is an implementation using them (it also makes reviewing them more difficult).

They are used by my dummy driver (link to the source is in the documentation). Handling uncombinable effects in lg4ff would be a bit more involved so I decided to add support for these in a separate patch series.

Quoted 11 lines

[...]

Quoted 9 lines

+4. Specifics of "ff-memless-next" for userspace developers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+None of the persons involved in development or testing of "ff-memless-next" +is aware of any reference force feedback specifications. "ff-memless-next" +tries to adhere to Microsoft's DirectInput specifications because we +believe that is what most developers have experience with.
+
+- Waveforms of periodic effects do not start at the origin, but as

Quoted 8 lines

Documentation/input/ff-memless-next.txt

Quoted 8 lines

follows: + SAW_UP: At minimum

Documentation/input/ff-memless-next.txt new file +7 -0
+	SAW_DOWN: At maximum
+	SQUARE: At maximum
+	TRIANGLE: At maximum
+	SINE: At origin
+
+- Updating periodic effects:
+	- All periodic effects are restarted when their parameters are 

updated.

Quoted 40 lines

Documentation/input/ff-memless-next.txt line 141

Quoted 6 lines
Documentation/input/ff-memless-next.txt new file +6 -0
+
+- Updating effects of finite duration:
+	- Once an effect of finite length finishes playing, it is considered
+	  stopped. Only effects that are playing can be updated on the fly.
+	  Therefore effects of finite duration can be updated only until
+	  they finish playing.

Stopped effects should still be able to be updated.

Anyway, if you want to target userspace developers with this information, you should put it in generic documentation ("it is not guaranteed that X", etc.). If not, don't say "for userspace developers".

[...]

Quoted 16 lines
(quoted diff) +0 -0

b/drivers/input/ff-memless-next.c new file mode 100644 index 0000000..843a223

drivers/input/ff-memless-next.c new file +4 -0
@@ -0,0 +1,789 @@
+/*
+ * Force feedback support for memoryless devices
+ *
+ * This module is based on "ff-memless" orignally written by Anssi

Hannula. + * It is extended to support all force feedback effects currently supported + * by the Linux input stack.
+ *
+ * Copyright(c) 2013 Michal Maly <[email protected]>
+ *
+ */

[...]

Quoted 3 lines
drivers/input/ff-memless-next.c new file +3 -0
+static int mlnx_upload(struct input_dev *dev, struct ff_effect *effect,
+		       struct ff_effect *old)
+{

[...]

Quoted 7 lines

drivers/input/ff-memless-next.c line 746

Quoted 5 lines
drivers/input/ff-memless-next.c new file +5 -0
+		}
+
+		mlnx_schedule_playback(mlnxdev);
+		spin_unlock_irq(&dev->event_lock);
+		return 0;

The above two lines are unneeded.

Oops...

Quoted 19 lines
Quoted 7 lines
drivers/input/ff-memless-next.c new file +7 -0
+	}
+
+	spin_unlock_irq(&dev->event_lock);
+
+	return 0;
+}
+

[...]

Quoted 6 lines
(quoted diff) +0 -0

b/include/linux/input/ff-memless-next.h new file mode 100644 index 0000000..ba89ba1

include/linux/input/ff-memless-next.h new file +0 -0
@@ -0,0 +1,32 @@

[...]

Quoted 2 lines

include/linux/input/ff-memless-next.h

Quoted 2 lines
include/linux/input/ff-memless-next.h new file +2 -0
+int input_ff_create_mlnx(struct input_dev *dev, void *data,
+			 int(*control_effect)(struct input_dev *, void *, const 

struct

Quoted 3 lines
Quoted 1 line

mlnx_effect_command *), + const u16 update_rate);

Why is update_rate now driver-selectable?

Because it is my intention to replace ff-memless with MLNX, I want to account for (very old?) devices that might have a limit on how many commands they can accept within a given timeframe. Update interval in ff-memless is 50 msecs whereas Logitech wheels can go as low as 8 msecs. The lower the update interval - the better the quality of periodic, ramp and envelope effects. Allowing the driver to choose how fast will MLNX generate updates seemed like the best way to go.

Your feedback is very much appreciated...

Michal M.

#4 lore raw

Re: [PATCH v2 1/4] Add ff-memless-next driver

In reply to Anssi Hannula

I forgot to comment on this:

Quoted 1 line

Stopped effects should still be able to be updated.

Fair enough. I could not find a definitive answer to what is expected behavior in this case. As far as I can tell, there are following cases:
- Effects with no duration and delay: they shall be updated right away.
- Effects with delay: updated parameters shall be sent to the device at the correct time.
- "Expired" effects with finite duration - ??? I assumed that effects with finite duration that have already finished playing cannot be updated because it does not seem to make much sense to do so. Shall such an effect be restarted when it is updated? Is there any guideline I should stick to I am not aware of?

Michal M.

#5 lore raw

Re: [PATCH v2 1/4] Add ff-memless-next driver

24.02.2014 03:54, Michal Malý kirjoitti:

Quoted 10 lines

I forgot to comment on this:

Quoted 1 line

Stopped effects should still be able to be updated.

Fair enough. I could not find a definitive answer to what is expected behavior in this case. As far as I can tell, there are following cases:
- Effects with no duration and delay: they shall be updated right away.
- Effects with delay: updated parameters shall be sent to the device at the correct time.
- "Expired" effects with finite duration - ??? I assumed that effects with finite duration that have already finished playing cannot be updated because it does not seem to make much sense to do so.

"Expired" effects can always be played back again later - if that happens, the updated parameters will be in effect.

Quoted 2 lines

Shall such an effect be
restarted when it is updated?

No.

Quoted 2 lines

Is there any guideline I should stick to I am
not aware of?

Only "3.7 Dynamic update of an effect" of input/ff.txt.

Signature · 5 lines
Anssi Hannula
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

Re: [PATCH v2 1/4] Add ff-memless-next driver

Quoted 14 lines · On Monday 24 of February 2014 04:11:04 Anssi Hannula wrote:

24.02.2014 03:54, Michal Malý kirjoitti:

Quoted 12 lines

I forgot to comment on this:

Quoted 1 line

Stopped effects should still be able to be updated.

Fair enough. I could not find a definitive answer to what is expected behavior in this case. As far as I can tell, there are following cases:
- Effects with no duration and delay: they shall be updated right away.
- Effects with delay: updated parameters shall be sent to the device at the
correct time.
- "Expired" effects with finite duration - ??? I assumed that effects with finite duration that have already finished playing cannot be updated because it does not seem to make much sense to do so.

Quoted 2 lines

"Expired" effects can always be played back again later - if that happens, the updated parameters will be in effect.

Okay, let me make this clear. When an effect "expires", update of its parameters shall not trigger a restart, therefore it will not play. However, when its parameters are updated and the effect is started again at some point, the updated parameters shall be used. I will double-check this just to be on the safe side, but MLNX always stores the updated parameters no matter what the status of the effect is, so it should behave exactly as you suggest. Perhaps it was just me misinterpreting the semantics of "update"?

To bring this to a conclusion:
- Do you think that this work is worth mainlining?
- If it is, what do you suggest I change?

Thanks a lot for your input.

Michal M.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw
In reply to Michal Malý
Quoted 20 lines · Michal Malý
Quoted 8 lines · On Monday 24 of February 2014 02:32:27 Anssi Hannula wrote:

I think we should extend the current ff-memless instead of duplicating its functionality (even on a "for now" basis).

Having looked at ff-memless-next briefly, it seems very similar to ff-memless on its basic working principle, and therefore I don't really see why extending ff-memless would be too cumbersome. Unless I'm missing something - in that case, feel free to point it out to me :)

Deciding whether to patch ff-memless or write a new driver from scratch was a perfect example of being caught between the rock and a hard place. I am not particularly fond of the fact that we would have two modules doing pretty much the same thing. My reasons for writing a separate module were:
- Periodic effects. ff-memless doesn't do "real" periodic effects, it simply emulates them through rumble effect. Devices without rumble effect support require emulation through constant force effect. Just this was not something one could write in one afternoon:)
- Conditional effects. These effects cannot be by nature combined into one overall force (at least not easily) so they have to be handled one by one -

Quoted 8 lines

this is a concept ff-memless does not seem to consider. FFB devices have limits as to how many conditional (referred to as "uncombinable" in MLNX) effects can be active simultaneously, etc.
All in all it seemed less error prone to write a new driver based on the ff- memless logic, test and deploy it on devices I have access to and once we are sure there are no nasty regressions port the rest of the drivers to the new API. Given the scope of the changes I am afraid that a "patch" to ff-memless would be pretty close to a rewrite anyway.

And add the fact that we already heavily tested the ff-memless-next driver. Unless you do a diff between the original ff-memless.c and the current ff-memless-next.c (which will result in a rather unintuitive patch), it would be a huge waste of time to retest the modified (when doing efforts to create an intuitive patch) ff-memless-next.c, considered my total time spend on testing (and not to speak of the time that Michal spent to fix the corresponding bugs.)
I know that might not be much of an argument, but on the other side, my motivation to test again from scratch will be much lower (I can't change much on that, I'm afraid), which would eventually lead to lower reliability of the final product.

Elias

maintainer
#13 lore raw
Quoted 30 lines · Elias Vanderstuyft
Quoted 20 lines · Michal Malý
Quoted 8 lines · On Monday 24 of February 2014 02:32:27 Anssi Hannula wrote:

I think we should extend the current ff-memless instead of duplicating its functionality (even on a "for now" basis).

Having looked at ff-memless-next briefly, it seems very similar to ff-memless on its basic working principle, and therefore I don't really see why extending ff-memless would be too cumbersome. Unless I'm missing something - in that case, feel free to point it out to me :)

Deciding whether to patch ff-memless or write a new driver from scratch was a perfect example of being caught between the rock and a hard place. I am not particularly fond of the fact that we would have two modules doing pretty much the same thing. My reasons for writing a separate module were:
- Periodic effects. ff-memless doesn't do "real" periodic effects, it simply emulates them through rumble effect. Devices without rumble effect support require emulation through constant force effect. Just this was not something one could write in one afternoon:)
- Conditional effects. These effects cannot be by nature combined into one overall force (at least not easily) so they have to be handled one by one -

Quoted 8 lines

this is a concept ff-memless does not seem to consider. FFB devices have limits as to how many conditional (referred to as "uncombinable" in MLNX) effects can be active simultaneously, etc.
All in all it seemed less error prone to write a new driver based on the ff- memless logic, test and deploy it on devices I have access to and once we are sure there are no nasty regressions port the rest of the drivers to the new API. Given the scope of the changes I am afraid that a "patch" to ff-memless would be pretty close to a rewrite anyway.

Quoted 11 lines

And add the fact that we already heavily tested the ff-memless-next driver. Unless you do a diff between the original ff-memless.c and the current ff-memless-next.c (which will result in a rather unintuitive patch), it would be a huge waste of time to retest the modified (when doing efforts to create an intuitive patch) ff-memless-next.c, considered my total time spend on testing (and not to speak of the time that Michal spent to fix the corresponding bugs.)
I know that might not be much of an argument, but on the other side, my motivation to test again from scratch will be much lower (I can't change much on that, I'm afraid), which would eventually lead to lower reliability of the final product.

On the other hand having 2 drivers implementing very similar functionality would lead to general confusion as to which one should be used; they will also have to be maintained.

I would rather see them merged into one driver providing necessary services to all memoryless FF devices.

Thanks.

Signature · 1 line
Dmitry
#14 lore raw
Quoted 2 lines · On Monday 24 of February 2014 13:48:18 Dmitry Torokhov wrote:
Quoted 1 line · Elias Vanderstuyft

On Mon, Feb 24, 2014 at 1:58 AM, Michal Malý <[email protected]>

Quoted 46 lines · wrote:
Quoted 33 lines
Quoted 24 lines · On Monday 24 of February 2014 02:32:27 Anssi Hannula wrote:
Quoted 8 lines

I think we should extend the current ff-memless instead of duplicating its functionality (even on a "for now" basis).

Having looked at ff-memless-next briefly, it seems very similar to ff-memless on its basic working principle, and therefore I don't really see why extending ff-memless would be too cumbersome. Unless I'm missing
something - in that case, feel free to point it out to me :)

Deciding whether to patch ff-memless or write a new driver from scratch was a perfect example of being caught between the rock and a hard place. I am not particularly fond of the fact that we would have two modules doing pretty much the same thing. My reasons for writing a separate module were:
- Periodic effects. ff-memless doesn't do "real" periodic effects, it simply emulates them through rumble effect. Devices without rumble effect support require emulation through constant force effect. Just this was not something one could write in one afternoon:)
- Conditional effects. These effects cannot be by nature combined into one
overall force (at least not easily) so they have to be handled one by one -
this is a concept ff-memless does not seem to consider. FFB devices have

Quoted 8 lines

limits as to how many conditional (referred to as "uncombinable" in MLNX)
effects can be active simultaneously, etc.
All in all it seemed less error prone to write a new driver based on the ff- memless logic, test and deploy it on devices I have access to and once we are sure there are no nasty regressions port the rest of the drivers to the new API. Given the scope of the changes I am afraid that a "patch" to ff-memless would be pretty close to a rewrite anyway.

Quoted 12 lines

And add the fact that we already heavily tested the ff-memless-next driver.
Unless you do a diff between the original ff-memless.c and the current ff-memless-next.c (which will result in a rather unintuitive patch), it would be a huge waste of time to retest the modified (when doing efforts to create an intuitive patch) ff-memless-next.c, considered my total time spend on testing (and not to speak of the time that Michal spent to fix the corresponding bugs.)
I know that might not be much of an argument, but on the other side, my motivation to test again from scratch will be much lower (I can't change much on that, I'm afraid), which would eventually lead to lower reliability of the final product.

Quoted 8 lines

On the other hand having 2 drivers implementing very similar functionality would lead to general confusion as to which one should be used; they will also have to be maintained.

I would rather see them merged into one driver providing necessary services to all memoryless FF devices.

Thanks.

Very well. It that case I guess the most sensible thing to do would be to add FF_RUMBLE to ff-memless-next and replace ff-memless completely. As Anssi pointed out a lot of the drivers that currently use ff-memless are very simple so any risk of breakage will hopefully be minimal.

As I don't have any device with rumble effect support I'll appreciate help on this front

Michal M.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html