Skip to contentSkip to conversation

input: Introduce ff-memless-next as an improved replacement for ff-memless

PATCH Superseded Michal Malý 4 participants 39 messages Apr 22, 2014 – Apr 27, 2014 2 messages not in the archive

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover input: Introduce ff-memless-next as an improved replacement for ff-memless

ff-memless-next (MLNX) is a largely improved version of the current ff-memless (FFML) driver. MLNX supports all force feedback effects currently available in the Linux force feedback userspace API. All effects are handled in accordance with Microsoft's DirectInput/XInput. Most notable changes include support for conditional effects, proper handling of all periodic waveforms and improved emulation of rumble effects through periodic effects. MLNX also uses its own kernel API to pass processed effects to hardware-specific drivers instead of abusing "ff_effect" struct. The API is documented in the respective header file.

MLNX has been expanded to be a direct replacement for FFML.

Support for FF_PERIODIC and FF_RAMP has been added to all devices that support FF_CONSTANT as a part of the port to the new API.

This patch series:
1) Adds "ff-memless-next" module [1]
2) Ports all hardware-specific drivers to MLNX's API [2-23]
3) Removes FFML and replaces it with MLNX [24]

v2:
- Add missing msecs to jiffies conversion in ff-memless-next
- lgff: Properly convert force on Y axis from MLNX to device range Support periodic effects for "joystick_ac" device class
- lg3ff: Properly convert forces from MLNX to device range
- Very minor coding style issues fixed

Michal Malý (24):
Add ff-memless-next module
Port arizona-haptics to ff-memless-next
Port twl4030-vibra to ff-memless-next
Port twl6040-vibra to ff-memless-next
Port max8997_haptic to ff-memless-next
Port pm8xxx-vibrator to ff-memless-next
Port hid-axff to ff-memless-next
Port hid-emsff to ff-memless-next
Port hid-dr to ff-memless-next
Port hid-gaff to ff-memless-next
Port hid-holtekff to ff-memless-next
Port hid-lgff to ff-memless-next
Port hid-lg3ff to ff-memless-next
Port hid-pl to ff-memless-next
Port hid-sjoy to ff-memless-next
Port hid-sony to ff-memless-next
Port hid-tmff to ff-memless-next
Port hid-wiimote-modules to ff-memless-next
Port hid-zpff to ff-memless-next
Port gamecon to ff-memless-next
Port xpad to ff-memless-next
- Port hid-lg2ff to ff-memless-next - Clamp vibration magnitude to

    range <0x02; 0xfd> to prevent irregular       shaking of the
    vibration motors.

Port hid-lg4ff to ff-memless-next
Replace ff-memless with ff-memless-next

 drivers/hid/Kconfig                   |   30 +-
 drivers/hid/hid-axff.c                |   32 +-
 drivers/hid/hid-dr.c                  |   59 +-
 drivers/hid/hid-emsff.c               |   38 +-
 drivers/hid/hid-gaff.c                |   32 +-
 drivers/hid/hid-holtekff.c            |   47 +-
 drivers/hid/hid-lg2ff.c               |   65 ++-
 drivers/hid/hid-lg3ff.c               |   60 +-
 drivers/hid/hid-lg4ff.c               |   93 +--
 drivers/hid/hid-lgff.c                |   70 ++-
 drivers/hid/hid-pl.c                  |   38 +-
 drivers/hid/hid-sjoy.c                |   35 +-
 drivers/hid/hid-sony.c                |   24 +-
 drivers/hid/hid-tmff.c                |   83 +--
 drivers/hid/hid-wiimote-modules.c     |   74 ++-
 drivers/hid/hid-zpff.c                |   30 +-
 drivers/input/Kconfig                 |    4 +-
 drivers/input/Makefile                |    2 +-
 drivers/input/ff-memless-next.c       | 1037 +++++++++++++++++++++++++++++++++
 drivers/input/ff-memless.c            |  547 -----------------
 drivers/input/joystick/Kconfig        |    4 +-
 drivers/input/joystick/gamecon.c      |   57 +-
 drivers/input/joystick/xpad.c         |  125 ++--
 drivers/input/misc/Kconfig            |   10 +-
 drivers/input/misc/arizona-haptics.c  |   39 +-
 drivers/input/misc/max8997_haptic.c   |   25 +-
 drivers/input/misc/pm8xxx-vibrator.c  |   28 +-
 drivers/input/misc/twl4030-vibra.c    |   31 +-
 drivers/input/misc/twl6040-vibra.c    |   27 +-
 include/linux/input.h                 |    3 -
 include/linux/input/ff-memless-next.h |  149 +++++
 31 files changed, 1939 insertions(+), 959 deletions(-)
 create mode 100644 drivers/input/ff-memless-next.c
 delete mode 100644 drivers/input/ff-memless.c
 create mode 100644 include/linux/input/ff-memless-next.h
Signature · 1 line
1.9.2
#1 lore raw

PATCH v2 1/24 input: Add ff-memless-next module

---
 drivers/input/Kconfig                 |   11 +
 drivers/input/Makefile                |    1 +
 drivers/input/ff-memless-next.c       | 1037 +++++++++++++++++++++++++++++++++
 include/linux/input/ff-memless-next.h |  149 +++++
 4 files changed, 1198 insertions(+)
 create mode 100644 drivers/input/ff-memless-next.c
 create mode 100644 include/linux/input/ff-memless-next.h
drivers/input/Kconfig +11 -0
index a11ff74..3780962 100644
@@ -38,6 +38,17 @@ config INPUT_FF_MEMLESS
 	  To compile this driver as a module, choose M here: the
 	  module will be called ff-memless.
 
+config INPUT_FF_MEMLESS_NEXT
+	tristate "New version of support for memoryless force-feedback devices"
+	help
+	  Say Y here to enable a new version of support for 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.
+
 config INPUT_POLLDEV
 	tristate "Polled input device skeleton"
 	help
drivers/input/Makefile +1 -0
index 5ca3f63..b4f11f5 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_INPUT)		+= input-core.o
 input-core-y := input.o input-compat.o input-mt.o ff-core.o
 
 obj-$(CONFIG_INPUT_FF_MEMLESS)	+= ff-memless.o
+obj-$(CONFIG_INPUT_FF_MEMLESS_NEXT)	+= ff-memless-next.o
 obj-$(CONFIG_INPUT_POLLDEV)	+= input-polldev.o
 obj-$(CONFIG_INPUT_SPARSEKMAP)	+= sparse-keymap.o
 obj-$(CONFIG_INPUT_MATRIXKMAP)	+= matrix-keymap.o
drivers/input/ff-memless-next.c new file +1037 -0

1,037 lines not on this page · raw message

include/linux/input/ff-memless-next.h new file +149 -0

149 lines not on this page · raw message

Signature · 6 lines
1.9.2

--
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 01/24] input: Add ff-memless-next module

Quoted 12 lines · Michal Malý
drivers/input/ff-memless-next.c new file +11 -0
+/* Some devices might have a limit on how many uncombinable effects
+ * can be played at once */
+static int mlnx_upload_conditional(struct mlnx_device *mlnxdev,
+                                  const struct ff_effect *effect)
+{
+       struct mlnx_effect_command ecmd = {
+               .cmd = MLNX_UPLOAD_UNCOMB,
+               .u.uncomb.id = effect->id,
+               .u.uncomb.effect = effect
+       };
+       return mlnxdev->control_effect(mlnxdev->dev, mlnxdev->private,

&ecmd);

Review

Quoted 2 lines
(quoted diff) +2 -0
+}
+

This mean you are building the structure on the stack

1. Are you sure nobody retains a reference?
2. That is needlessly inefficient

Regards
Oliver

--
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 01/24] input: Add ff-memless-next module

Quoted 18 lines · On Wednesday 23 of April 2014 14:12:59 Oliver Neukum wrote:
Quoted 12 lines · Michal Malý
drivers/input/ff-memless-next.c new file +11 -0
+/* Some devices might have a limit on how many uncombinable effects
+ * can be played at once */
+static int mlnx_upload_conditional(struct mlnx_device *mlnxdev,
+                                  const struct ff_effect *effect)
+{
+       struct mlnx_effect_command ecmd = {
+               .cmd = MLNX_UPLOAD_UNCOMB,
+               .u.uncomb.id = effect->id,
+               .u.uncomb.effect = effect
+       };
+       return mlnxdev->control_effect(mlnxdev->dev, mlnxdev->private,

&ecmd);

Review

Quoted 2 lines
(quoted diff) +2 -0
+}
+

This mean you are building the structure on the stack

Quoted 1 line

1. Are you sure nobody retains a reference?

Yes. The command is a one-shot thing so it makes no sense to hold a persistent reference to it. Should the HW-specific driver need to keep any data from the command - if the uses a workqueue to submit data to the device for instance - it should keep its own copy of the data. The idea is to keep MLNX and HW- specific driver as separated as possible to prevent any race conditions.

Quoted 1 line

2. That is needlessly inefficient

Are you suggesting I drop the 'consts' and keep the memory preallocated?

Thanks for the feedback,
Michal

#4 lore raw

Re: [PATCH v2 01/24] input: Add ff-memless-next module

Quoted 2 lines · Michal Malý
Quoted 1 line

2. That is needlessly inefficient

Are you suggesting I drop the 'consts' and keep the memory preallocated?

Yes.

Regards
Oliver

maintainer
#5 lore raw

Re: [PATCH v2 01/24] input: Add ff-memless-next module

In reply to Oliver Neukum
Quoted 18 lines · Oliver Neukum
Quoted 12 lines · Michal Malý
drivers/input/ff-memless-next.c new file +11 -0
+/* Some devices might have a limit on how many uncombinable effects
+ * can be played at once */
+static int mlnx_upload_conditional(struct mlnx_device *mlnxdev,
+                                  const struct ff_effect *effect)
+{
+       struct mlnx_effect_command ecmd = {
+               .cmd = MLNX_UPLOAD_UNCOMB,
+               .u.uncomb.id = effect->id,
+               .u.uncomb.effect = effect
+       };
+       return mlnxdev->control_effect(mlnxdev->dev, mlnxdev->private,

&ecmd);

Review

Quoted 2 lines
(quoted diff) +2 -0
+}
+

This mean you are building the structure on the stack

Quoted 2 lines

1. Are you sure nobody retains a reference?
2. That is needlessly inefficient

Why is it inefficient?

Signature · 1 line
Dmitry
#6 lore raw

Re: [PATCH v2 01/24] input: Add ff-memless-next module

Quoted 19 lines · Dmitry Torokhov
Quoted 18 lines · Oliver Neukum
Quoted 12 lines · Michal Malý
drivers/input/ff-memless-next.c new file +11 -0
+/* Some devices might have a limit on how many uncombinable effects
+ * can be played at once */
+static int mlnx_upload_conditional(struct mlnx_device *mlnxdev,
+                                  const struct ff_effect *effect)
+{
+       struct mlnx_effect_command ecmd = {
+               .cmd = MLNX_UPLOAD_UNCOMB,
+               .u.uncomb.id = effect->id,
+               .u.uncomb.effect = effect
+       };
+       return mlnxdev->control_effect(mlnxdev->dev, mlnxdev->private,

&ecmd);

Review

Quoted 2 lines
(quoted diff) +2 -0
+}
+

This mean you are building the structure on the stack

Quoted 4 lines
Quoted 2 lines

1. Are you sure nobody retains a reference?
2. That is needlessly inefficient

Why is it inefficient?

The compiler has to include the data structure and then make a memcopy to the stack. Instead a pointer to the predined structure could be passed.

Regards
Oliver

--
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

maintainer
#7 lore raw

Re: [PATCH v2 01/24] input: Add ff-memless-next module

Quoted 20 lines · Oliver Neukum
Quoted 19 lines · Dmitry Torokhov
Quoted 18 lines · Oliver Neukum
Quoted 12 lines · Michal Malý
drivers/input/ff-memless-next.c new file +11 -0
+/* Some devices might have a limit on how many uncombinable effects
+ * can be played at once */
+static int mlnx_upload_conditional(struct mlnx_device *mlnxdev,
+                                  const struct ff_effect *effect)
+{
+       struct mlnx_effect_command ecmd = {
+               .cmd = MLNX_UPLOAD_UNCOMB,
+               .u.uncomb.id = effect->id,
+               .u.uncomb.effect = effect
+       };
+       return mlnxdev->control_effect(mlnxdev->dev, mlnxdev->private,

&ecmd);

Review

Quoted 2 lines
(quoted diff) +2 -0
+}
+

This mean you are building the structure on the stack

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

1. Are you sure nobody retains a reference?
2. That is needlessly inefficient

Why is it inefficient?

The compiler has to include the data structure and then make a memcopy to the stack. Instead a pointer to the predined structure could be passed.

No, it does not do that. Memory on stack is reserved and zeroed out, then individual members are filled in as requested. There is no memcopy.

Thanks.

Signature · 5 lines
Dmitry
--
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 2/24 input: Port arizona-haptics to ff-memless-next

In reply to Michal Malý

Port arizona-haptics to ff-memless-next

---
 drivers/input/misc/Kconfig           |  2 +-
 drivers/input/misc/arizona-haptics.c | 39 +++++++++++++++++++++++-------------
 2 files changed, 26 insertions(+), 15 deletions(-)
drivers/input/misc/Kconfig +1 -1
index 7904ab0..33e0f5d 100644
@@ -75,7 +75,7 @@ config INPUT_AD714X_SPI
 config INPUT_ARIZONA_HAPTICS
 	tristate "Arizona haptics support"
 	depends on MFD_ARIZONA && SND_SOC
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	help
 	  Say Y to enable support for the haptics module in Arizona CODECs.
 
drivers/input/misc/arizona-haptics.c +25 -14
index ef2e281..b4707cc 100644
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/input.h>
+#include <linux/input/ff-memless-next.h>
 #include <linux/slab.h>
 
 #include <sound/soc.h>
@@ -22,6 +23,8 @@
 #include <linux/mfd/arizona/pdata.h>
 #include <linux/mfd/arizona/registers.h>
 
+#define FF_UPDATE_RATE 50
+
 struct arizona_haptics {
 	struct arizona *arizona;
 	struct input_dev *input_dev;
@@ -108,29 +111,37 @@ static void arizona_haptics_work(struct work_struct *work)
 }
 
 static int arizona_haptics_play(struct input_dev *input, void *data,
-				struct ff_effect *effect)
+				const struct mlnx_effect_command *command)
 {
 	struct arizona_haptics *haptics = input_get_drvdata(input);
 	struct arizona *arizona = haptics->arizona;
+	const struct mlnx_rumble_force *rumble_force = &command->u.rumble_force;
 
 	if (!arizona->dapm) {
 		dev_err(arizona->dev, "No DAPM context\n");
 		return -EBUSY;
 	}
 
-	if (effect->u.rumble.strong_magnitude) {
-		/* Scale the magnitude into the range the device supports */
-		if (arizona->pdata.hap_act) {
-			haptics->intensity =
-				effect->u.rumble.strong_magnitude >> 9;
-			if (effect->direction < 0x8000)
-				haptics->intensity += 0x7f;
+	switch (command->cmd) {
+	case MLNX_START_RUMBLE:
+		if (rumble_force->strong) {
+			/* Scale the magnitude into the range the device supports */
+			if (arizona->pdata.hap_act) {
+				haptics->intensity = rumble_force->strong >> 9;
+				if (rumble_force->strong_dir < 0x8000)
+					haptics->intensity += 0x7f;
+			} else {
+				haptics->intensity = rumble_force->strong >> 8;
+			}
 		} else {
-			haptics->intensity =
-				effect->u.rumble.strong_magnitude >> 8;
+			haptics->intensity = 0;
 		}
-	} else {
+		break;
+	case MLNX_STOP_RUMBLE:
 		haptics->intensity = 0;
+		break;
+	default:
+		return -EINVAL;
 	}
 
 	schedule_work(&haptics->work);
@@ -183,10 +194,10 @@ static int arizona_haptics_probe(struct platform_device *pdev)
 	haptics->input_dev->close = arizona_haptics_close;
 	__set_bit(FF_RUMBLE, haptics->input_dev->ffbit);
 
-	ret = input_ff_create_memless(haptics->input_dev, NULL,
-				      arizona_haptics_play);
+	ret = input_ff_create_mlnx(haptics->input_dev, NULL,
+				   arizona_haptics_play, FF_UPDATE_RATE);
 	if (ret < 0) {
-		dev_err(arizona->dev, "input_ff_create_memless() failed: %d\n",
+		dev_err(arizona->dev, "input_ff_create_mlnx() failed: %d\n",
 			ret);
 		goto err_ialloc;
 	}
Signature · 1 line
1.9.2
#9 lore raw

PATCH v2 3/24 input: Port twl4030-vibra to ff-memless-next

In reply to Michal Malý

Port twl4030-vibra to ff-memless-next

---
 drivers/input/misc/Kconfig         |  2 +-
 drivers/input/misc/twl4030-vibra.c | 31 +++++++++++++++++++++++++------
 2 files changed, 26 insertions(+), 7 deletions(-)
drivers/input/misc/Kconfig +1 -1
index 33e0f5d..1016a1b 100644
@@ -407,7 +407,7 @@ config INPUT_TWL4030_VIBRA
 	tristate "Support for TWL4030 Vibrator"
 	depends on TWL4030_CORE
 	select MFD_TWL4030_AUDIO
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	help
 	  This option enables support for TWL4030 Vibrator Driver.
 
drivers/input/misc/twl4030-vibra.c +25 -6
index 960ef2a..5274ad2 100644
@@ -32,9 +32,11 @@
 #include <linux/mfd/twl4030-audio.h>
 #include <linux/input.h>
 #include <linux/slab.h>
+#include <linux/input/ff-memless-next.h>
 
 /* MODULE ID2 */
 #define LEDEN		0x00
+#define FF_UPDATE_RATE	50
 
 /* ForceFeedback */
 #define EFFECT_DIR_180_DEG	0x8000 /* range is 0 - 0xFFFF */
@@ -134,14 +136,31 @@ static void vibra_play_work(struct work_struct *work)
 /*** Input/ForceFeedback ***/
 
 static int vibra_play(struct input_dev *input, void *data,
-		      struct ff_effect *effect)
+		      const struct mlnx_effect_command *command)
 {
 	struct vibra_info *info = input_get_drvdata(input);
+	const struct mlnx_rumble_force *rumble_force = &command->u.rumble_force;
+
+	switch (command->cmd) {
+	case MLNX_START_RUMBLE:
+		if (command->u.rumble_force.strong) {
+			info->speed = rumble_force->strong >> 8;
+			info->direction = rumble_force->strong_dir < EFFECT_DIR_180_DEG ?
+					  0 : 1;
+		} else {
+			info->speed = rumble_force->weak >> 9;
+			info->direction = rumble_force->weak_dir < EFFECT_DIR_180_DEG ?
+					  0 : 1;
+		}
+		break;
+	case MLNX_STOP_RUMBLE:
+		info->speed = 0;
+		info->direction = 0;
+		break;
+	default:
+		return -EINVAL;
+	}
 
-	info->speed = effect->u.rumble.strong_magnitude >> 8;
-	if (!info->speed)
-		info->speed = effect->u.rumble.weak_magnitude >> 9;
-	info->direction = effect->direction < EFFECT_DIR_180_DEG ? 0 : 1;
 	schedule_work(&info->play_work);
 	return 0;
 }
@@ -227,7 +246,7 @@ static int twl4030_vibra_probe(struct platform_device *pdev)
 	info->input_dev->close = twl4030_vibra_close;
 	__set_bit(FF_RUMBLE, info->input_dev->ffbit);
 
-	ret = input_ff_create_memless(info->input_dev, NULL, vibra_play);
+	ret = input_ff_create_mlnx(info->input_dev, NULL, vibra_play, FF_UPDATE_RATE);
 	if (ret < 0) {
 		dev_dbg(&pdev->dev, "couldn't register vibrator to FF\n");
 		return ret;
Signature · 6 lines
1.9.2

--
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

PATCH v2 4/24 input: Port twl6040-vibra to ff-memless-next

In reply to Michal Malý

Port twl6040-vibra to ff-memless-next

---
 drivers/input/misc/Kconfig         |  2 +-
 drivers/input/misc/twl6040-vibra.c | 27 ++++++++++++++++++++++-----
 2 files changed, 23 insertions(+), 6 deletions(-)
drivers/input/misc/Kconfig +1 -1
index 1016a1b..91dcae8 100644
@@ -417,7 +417,7 @@ config INPUT_TWL4030_VIBRA
 config INPUT_TWL6040_VIBRA
 	tristate "Support for TWL6040 Vibrator"
 	depends on TWL6040_CORE
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	help
 	  This option enables support for TWL6040 Vibrator Driver.
 
drivers/input/misc/twl6040-vibra.c +22 -5
index 77dc23b..7440a74 100644
@@ -30,12 +30,14 @@
 #include <linux/of.h>
 #include <linux/workqueue.h>
 #include <linux/input.h>
+#include <linux/input/ff-memless-next.h>
 #include <linux/mfd/twl6040.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/regulator/consumer.h>
 
 #define EFFECT_DIR_180_DEG	0x8000
+#define FF_UPDATE_RATE		50
 
 /* Recommended modulation index 85% */
 #define TWL6040_VIBRA_MOD	85
@@ -197,9 +199,10 @@ static void vibra_play_work(struct work_struct *work)
 }
 
 static int vibra_play(struct input_dev *input, void *data,
-		      struct ff_effect *effect)
+		      const struct mlnx_effect_command *command)
 {
 	struct vibra_info *info = input_get_drvdata(input);
+	const struct mlnx_rumble_force *rumble_force = &command->u.rumble_force;
 	int ret;
 
 	/* Do not allow effect, while the routing is set to use audio */
@@ -209,9 +212,23 @@ static int vibra_play(struct input_dev *input, void *data,
 		return -EBUSY;
 	}
 
-	info->weak_speed = effect->u.rumble.weak_magnitude;
-	info->strong_speed = effect->u.rumble.strong_magnitude;
-	info->direction = effect->direction < EFFECT_DIR_180_DEG ? 1 : -1;
+	switch (command->cmd) {
+	case MLNX_START_RUMBLE:
+		info->weak_speed = rumble_force->weak;
+		info->strong_speed = rumble_force->strong;
+		if (info->strong_speed >= info->weak_speed)
+			info->direction = rumble_force->strong_dir < EFFECT_DIR_180_DEG ? 1 : -1;
+		else
+			info->direction = rumble_force->weak_dir < EFFECT_DIR_180_DEG ? 1 : -1;
+		break;
+	case MLNX_STOP_RUMBLE:
+		info->weak_speed = 0;
+		info->strong_speed = 0;
+		info->direction = 1;
+		break;
+	default:
+		return -EINVAL;
+	}
 
 	ret = queue_work(info->workqueue, &info->play_work);
 	if (!ret) {
@@ -367,7 +384,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
 	info->input_dev->close = twl6040_vibra_close;
 	__set_bit(FF_RUMBLE, info->input_dev->ffbit);
 
-	ret = input_ff_create_memless(info->input_dev, NULL, vibra_play);
+	ret = input_ff_create_mlnx(info->input_dev, NULL, vibra_play, FF_UPDATE_RATE);
 	if (ret < 0) {
 		dev_err(info->dev, "couldn't register vibrator to FF\n");
 		goto err_ialloc;
Signature · 6 lines
1.9.2

--
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

PATCH v2 5/24 input: Port max8997_haptic to ff-memless-next

In reply to Michal Malý

Port max8997_haptic to ff-memless-next

---
 drivers/input/misc/Kconfig          |  2 +-
 drivers/input/misc/max8997_haptic.c | 25 +++++++++++++++++++------
 2 files changed, 20 insertions(+), 7 deletions(-)
drivers/input/misc/Kconfig +1 -1
index 91dcae8..6ba327f 100644
@@ -157,7 +157,7 @@ config INPUT_MAX8925_ONKEY
 config INPUT_MAX8997_HAPTIC
 	tristate "MAXIM MAX8997 haptic controller support"
 	depends on PWM && HAVE_PWM && MFD_MAX8997
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	help
 	  This option enables device driver support for the haptic controller
 	  on MAXIM MAX8997 chip. This driver supports ff-memless interface
drivers/input/misc/max8997_haptic.c +19 -6
index 1fea548..029ac8b 100644
@@ -31,6 +31,7 @@
 #include <linux/mfd/max8997-private.h>
 #include <linux/mfd/max8997.h>
 #include <linux/regulator/consumer.h>
+#include <linux/input/ff-memless-next.h>
 
 /* Haptic configuration 2 register */
 #define MAX8997_MOTOR_TYPE_SHIFT	7
@@ -43,6 +44,8 @@
 #define MAX8997_SIG_DUTY_SHIFT		2
 #define MAX8997_PWM_DUTY_SHIFT		0
 
+#define FF_UPDATE_RATE 50
+
 struct max8997_haptic {
 	struct device *dev;
 	struct i2c_client *client;
@@ -219,13 +222,23 @@ static void max8997_haptic_play_effect_work(struct work_struct *work)
 }
 
 static int max8997_haptic_play_effect(struct input_dev *dev, void *data,
-				  struct ff_effect *effect)
+				  const struct mlnx_effect_command *command)
 {
 	struct max8997_haptic *chip = input_get_drvdata(dev);
+	const struct mlnx_rumble_force *rumble_force = &command->u.rumble_force;
 
-	chip->level = effect->u.rumble.strong_magnitude;
-	if (!chip->level)
-		chip->level = effect->u.rumble.weak_magnitude;
+	switch (command->cmd) {
+	case MLNX_START_RUMBLE:
+		chip->level = rumble_force->strong;
+		if (!chip->level)
+			chip->level = rumble_force->weak;
+		break;
+	case MLNX_STOP_RUMBLE:
+		chip->level = 0;
+		break;
+	default:
+		return -EINVAL;
+	}
 
 	schedule_work(&chip->work);
 
@@ -319,8 +332,8 @@ static int max8997_haptic_probe(struct platform_device *pdev)
 	input_set_drvdata(input_dev, chip);
 	input_set_capability(input_dev, EV_FF, FF_RUMBLE);
 
-	error = input_ff_create_memless(input_dev, NULL,
-				max8997_haptic_play_effect);
+	error = input_ff_create_mlnx(input_dev, NULL,
+				max8997_haptic_play_effect, FF_UPDATE_RATE);
 	if (error) {
 		dev_err(&pdev->dev,
 			"unable to create FF device, error: %d\n",
Signature · 6 lines
1.9.2

--
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

PATCH v2 6/24 input: Port pm8xxx-vibrator to ff-memless-next

In reply to Michal Malý

Port pm8xxx-vibrator to ff-memless-next

---
 drivers/input/misc/Kconfig           |  2 +-
 drivers/input/misc/pm8xxx-vibrator.c | 28 +++++++++++++++++++---------
 2 files changed, 20 insertions(+), 10 deletions(-)
drivers/input/misc/Kconfig +1 -1
index 6ba327f..300b5a8 100644
@@ -108,7 +108,7 @@ config INPUT_PCSPKR
 config INPUT_PM8XXX_VIBRATOR
 	tristate "Qualcomm PM8XXX vibrator support"
 	depends on MFD_PM8XXX
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	help
 	  This option enables device driver support for the vibrator
 	  on Qualcomm PM8xxx chip. This driver supports ff-memless interface
drivers/input/misc/pm8xxx-vibrator.c +19 -9
index b88b7cb..6b0e9eb 100644
@@ -17,6 +17,7 @@
 #include <linux/input.h>
 #include <linux/slab.h>
 #include <linux/regmap.h>
+#include <linux/input/ff-memless-next.h>
 
 #define VIB_DRV			0x4A
 
@@ -29,7 +30,7 @@
 #define VIB_MAX_LEVELS		(VIB_MAX_LEVEL_mV - VIB_MIN_LEVEL_mV)
 
 #define MAX_FF_SPEED		0xff
-
+#define FF_UPDATE_RATE		50
 /**
  * struct pm8xxx_vib - structure to hold vibrator data
  * @vib_input_dev: input device supporting force feedback
@@ -128,14 +129,23 @@ static void pm8xxx_vib_close(struct input_dev *dev)
  * Currently this driver supports only rumble effects.
  */
 static int pm8xxx_vib_play_effect(struct input_dev *dev, void *data,
-				  struct ff_effect *effect)
+				  const struct mlnx_command *command)
 {
 	struct pm8xxx_vib *vib = input_get_drvdata(dev);
-
-	vib->speed = effect->u.rumble.strong_magnitude >> 8;
-	if (!vib->speed)
-		vib->speed = effect->u.rumble.weak_magnitude >> 9;
-
+	const struct mlnx_rumble_force *rumble_force = &command->u.rumble_force;
+
+	switch (command->cmd) {
+	case MLNX_START_RUMBLE:
+		vib->speed = rumble_force->strong >> 8;
+		if (!vib->speed)
+			vib->speed = rumble_force->weak >> 9;
+		break;
+	case MLNX_STOP_RUMBLE:
+		vib->speed = 0;
+		break;
+	default:
+		return -EINVAL;
+	}
 	schedule_work(&vib->work);
 
 	return 0;
@@ -182,8 +192,8 @@ static int pm8xxx_vib_probe(struct platform_device *pdev)
 	input_set_drvdata(input_dev, vib);
 	input_set_capability(vib->vib_input_dev, EV_FF, FF_RUMBLE);
 
-	error = input_ff_create_memless(input_dev, NULL,
-					pm8xxx_vib_play_effect);
+	error = input_ff_create_mlnx(input_dev, NULL,
+				     pm8xxx_vib_play_effect, FF_UPDATE_RATE);
 	if (error) {
 		dev_err(&pdev->dev,
 			"couldn't register vibrator as FF device\n");
Signature · 6 lines
1.9.2

--
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
#13 lore raw

PATCH v2 7/24 input: Port hid-axff to ff-memless-next

In reply to Michal Malý

Port hid-axff to ff-memless-next

---
 drivers/hid/Kconfig    |  2 +-
 drivers/hid/hid-axff.c | 32 +++++++++++++++++++++++---------
 2 files changed, 24 insertions(+), 10 deletions(-)
drivers/hid/Kconfig +1 -1
index f722001..68c19a0 100644
@@ -106,7 +106,7 @@ config HID_ACRUX
 config HID_ACRUX_FF
 	bool "ACRUX force feedback support"
 	depends on HID_ACRUX
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	Say Y here if you want to enable force feedback support for ACRUX
 	game controllers.
drivers/hid/hid-axff.c +23 -9
index a594e47..7fbfcbc 100644
@@ -31,31 +31,45 @@
 #include <linux/slab.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/input/ff-memless-next.h>
 
 #include "hid-ids.h"
 
+#define FF_UPDATE_RATE 50
 #ifdef CONFIG_HID_ACRUX_FF
 
 struct axff_device {
 	struct hid_report *report;
 };
 
-static int axff_play(struct input_dev *dev, void *data, struct ff_effect *effect)
+static int axff_play(struct input_dev *dev, void *data,
+		     const struct mlnx_effect_command *command)
 {
 	struct hid_device *hid = input_get_drvdata(dev);
 	struct axff_device *axff = data;
 	struct hid_report *report = axff->report;
+	const struct mlnx_rumble_force *rumble_force = &command->u.rumble_force;
 	int field_count = 0;
 	int left, right;
 	int i, j;
 
-	left = effect->u.rumble.strong_magnitude;
-	right = effect->u.rumble.weak_magnitude;
-
-	dbg_hid("called with 0x%04x 0x%04x", left, right);
-
-	left = left * 0xff / 0xffff;
-	right = right * 0xff / 0xffff;
+	switch (command->cmd) {
+	case MLNX_START_RUMBLE:
+		left = rumble_force->strong;
+		right = rumble_force->weak;
+
+		dbg_hid("called with 0x%04x 0x%04x", left, right);
+
+		left = left * 0xff / 0xffff;
+		right = right * 0xff / 0xffff;
+		break;
+	case MLNX_STOP_RUMBLE:
+		left = 0;
+		right = 0;
+		break;
+	default:
+		return -EINVAL;
+	}
 
 	for (i = 0; i < report->maxfield; i++) {
 		for (j = 0; j < report->field[i]->report_count; j++) {
@@ -107,7 +121,7 @@ static int axff_init(struct hid_device *hid)
 
 	set_bit(FF_RUMBLE, dev->ffbit);
 
-	error = input_ff_create_memless(dev, axff, axff_play);
+	error = input_ff_create_mlnx(dev, axff, axff_play, FF_UPDATE_RATE);
 	if (error)
 		goto err_free_mem;
 
Signature · 1 line
1.9.2
#14 lore raw

PATCH v2 8/24 input: Port hid-emsff to ff-memless-next

In reply to Michal Malý

Port hid-emsff to ff-memless-next

---
 drivers/hid/Kconfig     |  2 +-
 drivers/hid/hid-emsff.c | 38 ++++++++++++++++++++++++++------------
 2 files changed, 27 insertions(+), 13 deletions(-)
drivers/hid/Kconfig +1 -1
index 68c19a0..6e233d2 100644
@@ -204,7 +204,7 @@ config DRAGONRISE_FF
 config HID_EMS_FF
 	tristate "EMS Production Inc. force feedback support"
 	depends on HID
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	Say Y here if you want to enable force feedback support for devices by
 	EMS Production Ltd.
drivers/hid/hid-emsff.c +26 -12
index d82d75b..c0cbe50 100644
@@ -24,30 +24,44 @@
 #include <linux/hid.h>
 #include <linux/input.h>
 #include <linux/module.h>
+#include <linux/input/ff-memless-next.h>
 
 #include "hid-ids.h"
 
+#define FF_UPDATE_RATE 50
+
 struct emsff_device {
 	struct hid_report *report;
 };
 
 static int emsff_play(struct input_dev *dev, void *data,
-			 struct ff_effect *effect)
+			 const struct mlnx_effect_command *command)
 {
 	struct hid_device *hid = input_get_drvdata(dev);
 	struct emsff_device *emsff = data;
+	const struct mlnx_rumble_force *rumble_force = &command->u.rumble_force;
 	int weak, strong;
 
-	weak = effect->u.rumble.weak_magnitude;
-	strong = effect->u.rumble.strong_magnitude;
-
-	dbg_hid("called with 0x%04x 0x%04x\n", strong, weak);
-
-	weak = weak * 0xff / 0xffff;
-	strong = strong * 0xff / 0xffff;
-
-	emsff->report->field[0]->value[1] = weak;
-	emsff->report->field[0]->value[2] = strong;
+	switch (command->cmd) {
+	case MLNX_START_RUMBLE:
+		weak = rumble_force->weak;
+		strong = rumble_force->strong;
+
+		dbg_hid("called with 0x%04x 0x%04x\n", strong, weak);
+
+		weak = weak * 0xff / 0xffff;
+		strong = strong * 0xff / 0xffff;
+
+		emsff->report->field[0]->value[1] = weak;
+		emsff->report->field[0]->value[2] = strong;
+		break;
+	case MLNX_STOP_RUMBLE:
+		weak = 0;
+		strong = 0;
+		break;
+	default:
+		return -EINVAL;
+	}
 
 	dbg_hid("running with 0x%02x 0x%02x\n", strong, weak);
 	hid_hw_request(hid, emsff->report, HID_REQ_SET_REPORT);
@@ -88,7 +102,7 @@ static int emsff_init(struct hid_device *hid)
 
 	set_bit(FF_RUMBLE, dev->ffbit);
 
-	error = input_ff_create_memless(dev, emsff, emsff_play);
+	error = input_ff_create_mlnx(dev, emsff, emsff_play, FF_UPDATE_RATE);
 	if (error) {
 		kfree(emsff);
 		return error;
Signature · 1 line
1.9.2
#15 lore raw

PATCH v2 9/24 input: Port hid-dr to ff-memless-next

In reply to Michal Malý

Port hid-dr to ff-memless-next

---
 drivers/hid/Kconfig  |  2 +-
 drivers/hid/hid-dr.c | 59 ++++++++++++++++++++++++++++++++--------------------
 2 files changed, 37 insertions(+), 24 deletions(-)
drivers/hid/Kconfig +1 -1
index 6e233d2..0ba1962 100644
@@ -196,7 +196,7 @@ config HID_DRAGONRISE
 config DRAGONRISE_FF
 	bool "DragonRise Inc. force feedback"
 	depends on HID_DRAGONRISE
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	Say Y here if you want to enable force feedback support for DragonRise Inc.
 	game controllers.
drivers/hid/hid-dr.c +36 -23

89 lines not on this page · raw message

Signature · 1 line
1.9.2
#16 lore raw

Re: [PATCH v2 09/24] input: Port hid-dr to ff-memless-next

Quoted 50 lines · Michal Malý

static int drff_play(struct input_dev *dev, void *data,

drivers/hid/hid-dr.c +2 -1
-                                struct ff_effect *effect)
+                       const struct mlnx_effect_command *command)
 {
        struct hid_device *hid = input_get_drvdata(dev);
        struct drff_device *drff = data;
+       const struct mlnx_rumble_force *rumble_force =
&command->u.rumble_force;
        int strong, weak;
drivers/hid/hid-dr.c +2 -7
-       strong = effect->u.rumble.strong_magnitude;
-       weak = effect->u.rumble.weak_magnitude;
+       strong = rumble_force->strong;
+       weak = rumble_force->weak;
 
        dbg_hid("called with 0x%04x 0x%04x", strong, weak);
 
-       if (strong || weak) {
-               strong = strong * 0xff / 0xffff;
-               weak = weak * 0xff / 0xffff;
-
-               /* While reverse engineering this device, I found that

when
- this value is set, it causes the strong rumble to
function

drivers/hid/hid-dr.c +7 -13
-                  at a near maximum speed, so we'll bypass it. */
-               if (weak == 0x0a)
-                       weak = 0x0b;
-
-               drff->report->field[0]->value[0] = 0x51;
-               drff->report->field[0]->value[1] = 0x00;
-               drff->report->field[0]->value[2] = weak;
-               drff->report->field[0]->value[4] = strong;
-               hid_hw_request(hid, drff->report, HID_REQ_SET_REPORT);
-
-               drff->report->field[0]->value[0] = 0xfa;
-               drff->report->field[0]->value[1] = 0xfe;
-       } else {
+       switch (command->cmd) {
+       case MLNX_START_RUMBLE:
+               if (strong || weak) {
+                       strong = strong * 0xff / 0xffff;
+                       weak = weak * 0xff / 0xffff;
+
+                       /* While reverse engineering this device, I

found that when
+ this value is set, it causes the strong rumble
to function
+ at a near maximum speed, so we'll bypass it.
*/

drivers/hid/hid-dr.c struct drff_device { · line 73

Quoted 7 lines
drivers/hid/hid-dr.c +7 -0
+                       if (weak == 0x0a)
+                               weak = 0x0b;
+
+                       drff->report->field[0]->value[0] = 0x51;
+                       drff->report->field[0]->value[1] = 0x00;
+                       drff->report->field[0]->value[2] = weak;
+                       drff->report->field[0]->value[4] = strong;

This looks like an endianness bug.

Quoted 2 lines

+ hid_hw_request(hid, drff->report,
HID_REQ_SET_REPORT);

Regards
Oliver

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#19 lore raw

Re: [PATCH v2 09/24] input: Port hid-dr to ff-memless-next

Quoted 10 lines
Quoted 4 lines · On Wed, Apr 23, 2014 at 03:14:44PM +0000, [email protected] wrote:

This is another case where even the old code was flawed, right? Should I try to stuff the fixes into these patches or would a few extra patches addressing these problems be an easier to review solution? I can append such patches to the MLNX patchset.

Changes addressing pre-existing problem should go into separate patches (preferably applicable first).

As a by-stander who would like to see MLNX move forward, should it be heldback by pre-existing problems in drivers that the MLNX dev(s) don't have hardware to test against...?

Simon.

#20 lore raw

Re: [PATCH v2 09/24] input: Port hid-dr to ff-memless-next

Quoted 8 lines · On Wednesday 23 of April 2014 11:47:05 [email protected] wrote:
Quoted 8 lines

On Wed, Apr 23, 2014 at 03:14:44PM +0000, [email protected]

Quoted 4 lines · wrote:

This is another case where even the old code was flawed, right? Should I try to stuff the fixes into these patches or would a few extra patches addressing these problems be an easier to review solution? I can append such patches to the MLNX patchset.

Quoted 8 lines
Quoted 2 lines

Changes addressing pre-existing problem should go into separate patches (preferably applicable first).

As a by-stander who would like to see MLNX move forward, should it be heldback by pre-existing problems in drivers that the MLNX dev(s) don't have hardware to test against...?

Simon.

Either approach is fine be me - I can rebase the MLNX patchset against the fixes and submit it again. I suppose that this is a good opportunity to fix a bunch old issues that would pass unnoticed otherwise. I would however appreciate as much comments regarding MLNX itself before I begin cleaning the ancient dust.

Thanks for your input,
Michal

#21 lore raw

Re: [PATCH v2 09/24] input: Port hid-dr to ff-memless-next

In reply to Oliver Neukum
Quoted 57 lines · On Wednesday 23 of April 2014 15:41:03 Oliver Neukum wrote:
Quoted 56 lines · Michal Malý

static int drff_play(struct input_dev *dev, void *data,

drivers/hid/hid-dr.c +2 -1
-                                struct ff_effect *effect)
+                       const struct mlnx_effect_command *command)
 
 {
 
        struct hid_device *hid = input_get_drvdata(dev);
        struct drff_device *drff = data;
 
+       const struct mlnx_rumble_force *rumble_force =

&command->u.rumble_force;

        int strong, weak;
drivers/hid/hid-dr.c +2 -7
-       strong = effect->u.rumble.strong_magnitude;
-       weak = effect->u.rumble.weak_magnitude;
+       strong = rumble_force->strong;
+       weak = rumble_force->weak;
 
        dbg_hid("called with 0x%04x 0x%04x", strong, weak);
 
-       if (strong || weak) {
-               strong = strong * 0xff / 0xffff;
-               weak = weak * 0xff / 0xffff;
-
-               /* While reverse engineering this device, I found that

when
- this value is set, it causes the strong rumble to
function

drivers/hid/hid-dr.c +7 -13
-                  at a near maximum speed, so we'll bypass it. */
-               if (weak == 0x0a)
-                       weak = 0x0b;
-
-               drff->report->field[0]->value[0] = 0x51;
-               drff->report->field[0]->value[1] = 0x00;
-               drff->report->field[0]->value[2] = weak;
-               drff->report->field[0]->value[4] = strong;
-               hid_hw_request(hid, drff->report, HID_REQ_SET_REPORT);
-
-               drff->report->field[0]->value[0] = 0xfa;
-               drff->report->field[0]->value[1] = 0xfe;
-       } else {
+       switch (command->cmd) {
+       case MLNX_START_RUMBLE:
+               if (strong || weak) {
+                       strong = strong * 0xff / 0xffff;
+                       weak = weak * 0xff / 0xffff;
+
+                       /* While reverse engineering this device, I

found that when
+ this value is set, it causes the strong rumble
to function
+ at a near maximum speed, so we'll bypass it.
*/
+ if (weak == 0x0a)

Quoted 8 lines

drivers/hid/hid-dr.c struct drff_device { · line 73

Quoted 6 lines
drivers/hid/hid-dr.c +6 -0
+                               weak = 0x0b;
+
+                       drff->report->field[0]->value[0] = 0x51;
+                       drff->report->field[0]->value[1] = 0x00;
+                       drff->report->field[0]->value[2] = weak;
+                       drff->report->field[0]->value[4] = strong;

This looks like an endianness bug.

I don't have a big endian machine to check but why would this be an endianness issue? We're dealing with values all the time here, not addresses so I'd expect the 'weak' and 'strong' values to be truncated if they won't fit into byte. Division done beforehand makes sure that the values are within <0; 255> range. As far as I can see this is quite common in the HID and Input code. Am I missing something here?

Thanks,
Michal

#22 lore raw

Re: [PATCH v2 09/24] input: Port hid-dr to ff-memless-next

Quoted 67 lines · Michal Malý
Quoted 57 lines · On Wednesday 23 of April 2014 15:41:03 Oliver Neukum wrote:
Quoted 56 lines · Michal Malý

static int drff_play(struct input_dev *dev, void *data,

drivers/hid/hid-dr.c +2 -1
-                                struct ff_effect *effect)
+                       const struct mlnx_effect_command *command)
 
 {
 
        struct hid_device *hid = input_get_drvdata(dev);
        struct drff_device *drff = data;
 
+       const struct mlnx_rumble_force *rumble_force =

&command->u.rumble_force;

        int strong, weak;
drivers/hid/hid-dr.c +2 -7
-       strong = effect->u.rumble.strong_magnitude;
-       weak = effect->u.rumble.weak_magnitude;
+       strong = rumble_force->strong;
+       weak = rumble_force->weak;
 
        dbg_hid("called with 0x%04x 0x%04x", strong, weak);
 
-       if (strong || weak) {
-               strong = strong * 0xff / 0xffff;
-               weak = weak * 0xff / 0xffff;
-
-               /* While reverse engineering this device, I found that

when
- this value is set, it causes the strong rumble to
function

drivers/hid/hid-dr.c +7 -13
-                  at a near maximum speed, so we'll bypass it. */
-               if (weak == 0x0a)
-                       weak = 0x0b;
-
-               drff->report->field[0]->value[0] = 0x51;
-               drff->report->field[0]->value[1] = 0x00;
-               drff->report->field[0]->value[2] = weak;
-               drff->report->field[0]->value[4] = strong;
-               hid_hw_request(hid, drff->report, HID_REQ_SET_REPORT);
-
-               drff->report->field[0]->value[0] = 0xfa;
-               drff->report->field[0]->value[1] = 0xfe;
-       } else {
+       switch (command->cmd) {
+       case MLNX_START_RUMBLE:
+               if (strong || weak) {
+                       strong = strong * 0xff / 0xffff;
+                       weak = weak * 0xff / 0xffff;
+
+                       /* While reverse engineering this device, I

found that when
+ this value is set, it causes the strong rumble
to function
+ at a near maximum speed, so we'll bypass it.
*/
+ if (weak == 0x0a)

Quoted 8 lines

drivers/hid/hid-dr.c struct drff_device { · line 73

Quoted 6 lines
drivers/hid/hid-dr.c +6 -0
+                               weak = 0x0b;
+
+                       drff->report->field[0]->value[0] = 0x51;
+                       drff->report->field[0]->value[1] = 0x00;
+                       drff->report->field[0]->value[2] = weak;
+                       drff->report->field[0]->value[4] = strong;

This looks like an endianness bug.

Quoted 6 lines

I don't have a big endian machine to check but why would this be an endianness issue? We're dealing with values all the time here, not addresses so I'd expect the 'weak' and 'strong' values to be truncated if they won't fit into byte. Division done beforehand makes sure that the values are within <0; 255> range. As far as I can see this is quite common in the HID and Input code. Am I missing something here?

Sorry, I thought you were writing to 16bit variables.

Regards
Oliver

--
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

#23 lore raw

PATCH v2 10/24 input: Port hid-gaff to ff-memless-next

In reply to Michal Malý

Port hid-gaff to ff-memless-next

---
 drivers/hid/Kconfig    |  2 +-
 drivers/hid/hid-gaff.c | 32 +++++++++++++++++++++++---------
 2 files changed, 24 insertions(+), 10 deletions(-)
drivers/hid/Kconfig +1 -1
index 0ba1962..24b336e 100644
@@ -656,7 +656,7 @@ config HID_GREENASIA
 config GREENASIA_FF
 	bool "GreenAsia (Product ID 0x12) force feedback support"
 	depends on HID_GREENASIA
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	Say Y here if you have a GreenAsia (Product ID 0x12) based game controller
 	(like MANTA Warrior MM816 and SpeedLink Strike2 SL-6635) or adapter
drivers/hid/hid-gaff.c +23 -9
index 2d8cead..f2f70c1 100644
@@ -31,8 +31,11 @@
 #include <linux/slab.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/input/ff-memless-next.h>
 #include "hid-ids.h"
 
+#define FF_UPDATE_RATE 50
+
 #ifdef CONFIG_GREENASIA_FF
 
 struct gaff_device {
@@ -40,19 +43,30 @@ struct gaff_device {
 };
 
 static int hid_gaff_play(struct input_dev *dev, void *data,
-			 struct ff_effect *effect)
+			 const struct mlnx_effect_command *command)
 {
 	struct hid_device *hid = input_get_drvdata(dev);
 	struct gaff_device *gaff = data;
+	const struct mlnx_rumble_force *rumble_force = &command->u.rumble_force;
 	int left, right;
 
-	left = effect->u.rumble.strong_magnitude;
-	right = effect->u.rumble.weak_magnitude;
-
-	dbg_hid("called with 0x%04x 0x%04x", left, right);
-
-	left = left * 0xfe / 0xffff;
-	right = right * 0xfe / 0xffff;
+	switch (command->cmd) {
+	case MLNX_START_RUMBLE:
+		left = rumble_force->strong;
+		right = rumble_force->weak;
+
+		dbg_hid("called with 0x%04x 0x%04x", left, right);
+
+		left = left * 0xfe / 0xffff;
+		right = right * 0xfe / 0xffff;
+		break;
+	case MLNX_STOP_RUMBLE:
+		left = 0;
+		right = 0;
+		break;
+	default:
+		return -EINVAL;
+	}
 
 	gaff->report->field[0]->value[0] = 0x51;
 	gaff->report->field[0]->value[1] = 0x0;
@@ -109,7 +123,7 @@ static int gaff_init(struct hid_device *hid)
 
 	set_bit(FF_RUMBLE, dev->ffbit);
 
-	error = input_ff_create_memless(dev, gaff, hid_gaff_play);
+	error = input_ff_create_mlnx(dev, gaff, hid_gaff_play, FF_UPDATE_RATE);
 	if (error) {
 		kfree(gaff);
 		return error;
Signature · 1 line
1.9.2
#24 lore raw

PATCH v2 11/24 input: Port hid-holtekff to ff-memless-next

In reply to Michal Malý

Port hid-holtekff to ff-memless-next

---
 drivers/hid/Kconfig        |  2 +-
 drivers/hid/hid-holtekff.c | 47 +++++++++++++++++++++++++++++-----------------
 2 files changed, 31 insertions(+), 18 deletions(-)
drivers/hid/Kconfig +1 -1
index 24b336e..d1d4e77 100644
@@ -247,7 +247,7 @@ config HID_HOLTEK
 config HOLTEK_FF
 	bool "Holtek On Line Grip force feedback support"
 	depends on HID_HOLTEK
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	  Say Y here if you have a Holtek On Line Grip based game controller
 	  and want to have force feedback support for it.
drivers/hid/hid-holtekff.c +30 -17

80 lines not on this page · raw message

Signature · 6 lines
1.9.2

--
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
#25 lore raw

Re: [PATCH v2 11/24] input: Port hid-holtekff to ff-memless-next

Quoted 7 lines · Michal Malý

static int holtekff_play(struct input_dev *dev, void *data,

drivers/hid/hid-holtekff.c +2 -1
-                        struct ff_effect *effect)
+                        const struct mlnx_effect_command *command)
 {
        struct hid_device *hid = input_get_drvdata(dev);
        struct holtekff_device *holtekff = data;
+       const struct mlnx_rumble_force *rumble_force =
Quoted 5 lines
&command->u.rumble_force;
        int left, right;
        /* effect type 1, length 65535 msec */
        u8 buf[HOLTEKFF_MSG_LENGTH] =
                { 0x01, 0x01, 0xff, 0xff, 0x10, 0xe0, 0x00 };

On the kernel stack.

Quoted 39 lines
drivers/hid/hid-holtekff.c +13 -12
-       left = effect->u.rumble.strong_magnitude;
-       right = effect->u.rumble.weak_magnitude;
-       dbg_hid("called with 0x%04x 0x%04x\n", left, right);
+       switch (command->cmd) {
+       case MLNX_START_RUMBLE:
+               left = rumble_force->strong;
+               right = rumble_force->weak;
+               dbg_hid("called with 0x%04x 0x%04x\n", left, right);
 
-       if (!left && !right) {
-               holtekff_send(holtekff, hid, stop_all6);
-               return 0;
-       }
+               if (!left && !right) {
+                       holtekff_send(holtekff, hid, stop_all6);
+                       return 0;
+               }
 
-       if (left)
-               buf[1] |= 0x80;
-       if (right)
-               buf[1] |= 0x40;
+               if (left)
+                       buf[1] |= 0x80;
+               if (right)
+                       buf[1] |= 0x40;
 
-       /* The device takes a single magnitude, so we just sum them

up. */

(quoted diff) +1 -1
-       buf[6] = min(0xf, (left >> 12) + (right >> 12));
+               /* The device takes a single magnitude, so we just sum

them up. */

drivers/hid/hid-holtekff.c +3 -2
+               buf[6] = min(0xf, (left >> 12) + (right >> 12));
 
-       holtekff_send(holtekff, hid, buf);
-       holtekff_send(holtekff, hid, start_effect_1);
+               holtekff_send(holtekff, hid, buf);
+               holtekff_send(holtekff, hid, start_effect_1);

drivers/hid/hid-holtekff.c static void holtekff_send(struct holtekff_device *holtekff, · line 150

Quoted 10 lines
drivers/hid/hid-holtekff.c +7 -0
+               return 0;
+       case MLNX_STOP_RUMBLE:
+               holtekff_send(holtekff, hid, stop_all6);
+               return 0;
+       default:
+               return -EINVAL;
+       }
 
        return 0;
 }

This looks very much like doing DMA on the kernel stack. That is very strictly forbidden. The bug is also in the current code, but would you care to fix it up?

Regards
Oliver

#26 lore raw

Re: [PATCH v2 11/24] input: Port hid-holtekff to ff-memless-next

Quoted 68 lines · On Wednesday 23 of April 2014 14:17:50 Oliver Neukum wrote:
Quoted 13 lines · Michal Malý

static int holtekff_play(struct input_dev *dev, void *data,

drivers/hid/hid-holtekff.c +2 -1
-                        struct ff_effect *effect)
+                        const struct mlnx_effect_command *command)
 
 {
 
        struct hid_device *hid = input_get_drvdata(dev);
        struct holtekff_device *holtekff = data;
 
+       const struct mlnx_rumble_force *rumble_force =

&command->u.rumble_force;

Quoted 5 lines
        int left, right;
        /* effect type 1, length 65535 msec */
        u8 buf[HOLTEKFF_MSG_LENGTH] =
        
                { 0x01, 0x01, 0xff, 0xff, 0x10, 0xe0, 0x00 };

On the kernel stack.

Quoted 46 lines
drivers/hid/hid-holtekff.c +13 -12
-       left = effect->u.rumble.strong_magnitude;
-       right = effect->u.rumble.weak_magnitude;
-       dbg_hid("called with 0x%04x 0x%04x\n", left, right);
+       switch (command->cmd) {
+       case MLNX_START_RUMBLE:
+               left = rumble_force->strong;
+               right = rumble_force->weak;
+               dbg_hid("called with 0x%04x 0x%04x\n", left, right);
 
-       if (!left && !right) {
-               holtekff_send(holtekff, hid, stop_all6);
-               return 0;
-       }
+               if (!left && !right) {
+                       holtekff_send(holtekff, hid, stop_all6);
+                       return 0;
+               }
 
-       if (left)
-               buf[1] |= 0x80;
-       if (right)
-               buf[1] |= 0x40;
+               if (left)
+                       buf[1] |= 0x80;
+               if (right)
+                       buf[1] |= 0x40;
 
-       /* The device takes a single magnitude, so we just sum them

up. */

(quoted diff) +1 -1
-       buf[6] = min(0xf, (left >> 12) + (right >> 12));
+               /* The device takes a single magnitude, so we just sum

them up. */

drivers/hid/hid-holtekff.c +10 -2
+               buf[6] = min(0xf, (left >> 12) + (right >> 12));
 
-       holtekff_send(holtekff, hid, buf);
-       holtekff_send(holtekff, hid, start_effect_1);
+               holtekff_send(holtekff, hid, buf);
+               holtekff_send(holtekff, hid, start_effect_1);
+               return 0;
+       case MLNX_STOP_RUMBLE:
+               holtekff_send(holtekff, hid, stop_all6);
+               return 0;
+       default:
+               return -EINVAL;
+       }
Quoted 7 lines
Quoted 3 lines
        return 0;

}

This looks very much like doing DMA on the kernel stack. That is very strictly forbidden. The bug is also in the current code, but would you care to fix it up?

Okay, I'll look into it.

Michal

maintainer
#27 lore raw

Re: [PATCH v2 11/24] input: Port hid-holtekff to ff-memless-next

In reply to Oliver Neukum
Quoted 63 lines · Oliver Neukum
Quoted 7 lines · Michal Malý

static int holtekff_play(struct input_dev *dev, void *data,

drivers/hid/hid-holtekff.c +2 -1
-                        struct ff_effect *effect)
+                        const struct mlnx_effect_command *command)
 {
        struct hid_device *hid = input_get_drvdata(dev);
        struct holtekff_device *holtekff = data;
+       const struct mlnx_rumble_force *rumble_force =
Quoted 5 lines
&command->u.rumble_force;
        int left, right;
        /* effect type 1, length 65535 msec */
        u8 buf[HOLTEKFF_MSG_LENGTH] =
                { 0x01, 0x01, 0xff, 0xff, 0x10, 0xe0, 0x00 };

On the kernel stack.

Quoted 47 lines
drivers/hid/hid-holtekff.c +13 -12
-       left = effect->u.rumble.strong_magnitude;
-       right = effect->u.rumble.weak_magnitude;
-       dbg_hid("called with 0x%04x 0x%04x\n", left, right);
+       switch (command->cmd) {
+       case MLNX_START_RUMBLE:
+               left = rumble_force->strong;
+               right = rumble_force->weak;
+               dbg_hid("called with 0x%04x 0x%04x\n", left, right);
 
-       if (!left && !right) {
-               holtekff_send(holtekff, hid, stop_all6);
-               return 0;
-       }
+               if (!left && !right) {
+                       holtekff_send(holtekff, hid, stop_all6);
+                       return 0;
+               }
 
-       if (left)
-               buf[1] |= 0x80;
-       if (right)
-               buf[1] |= 0x40;
+               if (left)
+                       buf[1] |= 0x80;
+               if (right)
+                       buf[1] |= 0x40;
 
-       /* The device takes a single magnitude, so we just sum them

up. */

(quoted diff) +1 -1
-       buf[6] = min(0xf, (left >> 12) + (right >> 12));
+               /* The device takes a single magnitude, so we just sum

them up. */

drivers/hid/hid-holtekff.c +10 -2
+               buf[6] = min(0xf, (left >> 12) + (right >> 12));
 
-       holtekff_send(holtekff, hid, buf);
-       holtekff_send(holtekff, hid, start_effect_1);
+               holtekff_send(holtekff, hid, buf);
+               holtekff_send(holtekff, hid, start_effect_1);
+               return 0;
+       case MLNX_STOP_RUMBLE:
+               holtekff_send(holtekff, hid, stop_all6);
+               return 0;
+       default:
+               return -EINVAL;
+       }
Quoted 4 lines
Quoted 2 lines
        return 0;

}

This looks very much like doing DMA on the kernel stack.

It isn't:

static void holtekff_send(struct holtekff_device *holtekff,
struct hid_device *hid, const u8 data[HOLTEKFF_MSG_LENGTH])

{
        int i;

        for (i = 0; i < HOLTEKFF_MSG_LENGTH; i++) {
                holtekff->field->value[i] = data[i];
        }

        dbg_hid("sending %7ph\n", data);

        hid_hw_request(hid, holtekff->field->report, HID_REQ_SET_REPORT);
}

And also hid layer copies data a bunch of times over into DMA-safe buffers.

Quoted 7 lines

That is very strictly forbidden. The bug is also in the current code, but would you care to fix it up?

Regards
Oliver

Signature · 1 line
Dmitry
#28 lore raw

PATCH v2 12/24 input: Port hid-lgff to ff-memless-next

In reply to Michal Malý

Port hid-lgff to ff-memless-next

---
 drivers/hid/Kconfig    |  2 +-
 drivers/hid/hid-lgff.c | 70 +++++++++++++++++++++++++++++++++++---------------
 2 files changed, 51 insertions(+), 21 deletions(-)
drivers/hid/Kconfig +1 -1
index d1d4e77..c7794ae 100644
@@ -356,7 +356,7 @@ config HID_LOGITECH_DJ
 config LOGITECH_FF
 	bool "Logitech force feedback support"
 	depends on HID_LOGITECH
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	help
 	  Say Y here if you have one of these devices:
 	  - Logitech WingMan Cordless RumblePad
drivers/hid/hid-lgff.c +50 -20

122 lines not on this page · raw message

Signature · 1 line
1.9.2
#29 lore raw

PATCH v2 13/24 input: Port hid-lg3ff to ff-memless-next

In reply to Michal Malý

Port hid-lg3ff to ff-memless-next

---
 drivers/hid/Kconfig     |  2 +-
 drivers/hid/hid-lg3ff.c | 60 +++++++++++++++++++++++++++++++------------------
 2 files changed, 39 insertions(+), 23 deletions(-)
drivers/hid/Kconfig +1 -1
index c7794ae..6f2941a 100644
@@ -382,7 +382,7 @@ config LOGIRUMBLEPAD2_FF
 config LOGIG940_FF
 	bool "Logitech Flight System G940 force feedback support"
 	depends on HID_LOGITECH
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	help
 	  Say Y here if you want to enable force feedback support for Logitech
 	  Flight System G940 devices.
drivers/hid/hid-lg3ff.c +38 -22

102 lines not on this page · raw message

Signature · 1 line
1.9.2
#30 lore raw

PATCH v2 14/24 input: Port hid-pl to ff-memless-next

In reply to Michal Malý

Port hid-pl to ff-memless-next

---
 drivers/hid/Kconfig  |  2 +-
 drivers/hid/hid-pl.c | 38 ++++++++++++++++++++++++++------------
 2 files changed, 27 insertions(+), 13 deletions(-)
drivers/hid/Kconfig +1 -1
index 6f2941a..87a02cc 100644
@@ -500,7 +500,7 @@ config HID_PANTHERLORD
 config PANTHERLORD_FF
 	bool "Pantherlord force feedback support"
 	depends on HID_PANTHERLORD
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	  Say Y here if you have a PantherLord/GreenAsia based game controller
 	  or adapter and want to enable force feedback support for it.
drivers/hid/hid-pl.c +26 -12
index 2dcd7d9..9b539d5 100644
@@ -44,9 +44,12 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/hid.h>
+#include <linux/input/ff-memless-next.h>
 
 #include "hid-ids.h"
 
+#define FF_UPDATE_RATE 50
+
 #ifdef CONFIG_PANTHERLORD_FF
 
 struct plff_device {
@@ -57,24 +60,35 @@ struct plff_device {
 };
 
 static int hid_plff_play(struct input_dev *dev, void *data,
-			 struct ff_effect *effect)
+			 const struct mlnx_effect_command *command)
 {
 	struct hid_device *hid = input_get_drvdata(dev);
 	struct plff_device *plff = data;
+	const struct mlnx_rumble_force *rumble_force = &command->u.rumble_force;
 	int left, right;
 
-	left = effect->u.rumble.strong_magnitude;
-	right = effect->u.rumble.weak_magnitude;
-	debug("called with 0x%04x 0x%04x", left, right);
-
-	left = left * plff->maxval / 0xffff;
-	right = right * plff->maxval / 0xffff;
+	switch (command->cmd) {
+	case MLNX_START_RUMBLE:
+		left = rumble_force->strong;
+		right = rumble_force->weak;
+		debug("called with 0x%04x 0x%04x", left, right);
+
+		left = left * plff->maxval / 0xffff;
+		right = right * plff->maxval / 0xffff;
+
+		*plff->strong = left;
+		*plff->weak = right;
+		debug("running with 0x%02x 0x%02x", left, right);
+		break;
+	case MLNX_STOP_RUMBLE:
+		*plff->strong = 0;
+		*plff->weak = 0;
+		break;
+	default:
+		return -EINVAL;
+	}
 
-	*plff->strong = left;
-	*plff->weak = right;
-	debug("running with 0x%02x 0x%02x", left, right);
 	hid_hw_request(hid, plff->report, HID_REQ_SET_REPORT);
-
 	return 0;
 }
 
@@ -160,7 +174,7 @@ static int plff_init(struct hid_device *hid)
 
 		set_bit(FF_RUMBLE, dev->ffbit);
 
-		error = input_ff_create_memless(dev, plff, hid_plff_play);
+		error = input_ff_create_mlnx(dev, plff, hid_plff_play, FF_UPDATE_RATE);
 		if (error) {
 			kfree(plff);
 			return error;
Signature · 6 lines
1.9.2

--
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
#31 lore raw

PATCH v2 15/24 input: Port hid-sjoy to ff-memless-next

In reply to Michal Malý

Port hid-sjoy to ff-memless-next

---
 drivers/hid/Kconfig    |  2 +-
 drivers/hid/hid-sjoy.c | 35 +++++++++++++++++++++++++----------
 2 files changed, 26 insertions(+), 11 deletions(-)
drivers/hid/Kconfig +1 -1
index 87a02cc..e76c36a 100644
@@ -681,7 +681,7 @@ config HID_SMARTJOYPLUS
 config SMARTJOYPLUS_FF
 	bool "SmartJoy PLUS PS2/USB adapter force feedback support"
 	depends on HID_SMARTJOYPLUS
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	Say Y here if you have a SmartJoy PLUS PS2/USB adapter and want to
 	enable force feedback support for it.
drivers/hid/hid-sjoy.c +25 -10
index 37845ec..a6f8cfe 100644
@@ -30,8 +30,11 @@
 #include <linux/slab.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/input/ff-memless-next.h>
 #include "hid-ids.h"
 
+#define FF_UPDATE_RATE 50
+
 #ifdef CONFIG_SMARTJOYPLUS_FF
 
 struct sjoyff_device {
@@ -39,21 +42,33 @@ struct sjoyff_device {
 };
 
 static int hid_sjoyff_play(struct input_dev *dev, void *data,
-			 struct ff_effect *effect)
+			const struct mlnx_effect_command *command)
 {
 	struct hid_device *hid = input_get_drvdata(dev);
 	struct sjoyff_device *sjoyff = data;
+	const struct mlnx_rumble_force *rumble_force = &command->u.rumble_force;
 	u32 left, right;
 
-	left = effect->u.rumble.strong_magnitude;
-	right = effect->u.rumble.weak_magnitude;
-	dev_dbg(&dev->dev, "called with 0x%08x 0x%08x\n", left, right);
-
-	left = left * 0xff / 0xffff;
-	right = (right != 0); /* on/off only */
+	switch (command->cmd) {
+	case MLNX_START_RUMBLE:
+		left = rumble_force->strong;
+		right = rumble_force->weak;
+		dev_dbg(&dev->dev, "called with 0x%08x 0x%08x\n", left, right);
+
+		left = left * 0xff / 0xffff;
+		right = (right != 0); /* on/off only */
+
+		sjoyff->report->field[0]->value[1] = right;
+		sjoyff->report->field[0]->value[2] = left;
+		break;
+	case MLNX_STOP_RUMBLE:
+		left = 0;
+		right = 0;
+		break;
+	default:
+		return -EINVAL;
+	}
 
-	sjoyff->report->field[0]->value[1] = right;
-	sjoyff->report->field[0]->value[2] = left;
 	dev_dbg(&dev->dev, "running with 0x%02x 0x%02x\n", left, right);
 	hid_hw_request(hid, sjoyff->report, HID_REQ_SET_REPORT);
 
@@ -103,7 +118,7 @@ static int sjoyff_init(struct hid_device *hid)
 
 		set_bit(FF_RUMBLE, dev->ffbit);
 
-		error = input_ff_create_memless(dev, sjoyff, hid_sjoyff_play);
+		error = input_ff_create_mlnx(dev, sjoyff, hid_sjoyff_play, FF_UPDATE_RATE);
 		if (error) {
 			kfree(sjoyff);
 			return error;
Signature · 6 lines
1.9.2

--
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
#32 lore raw

PATCH v2 16/24 input: Port hid-sony to ff-memless-next

In reply to Michal Malý

Port hid-sony to ff-memless-next

---
 drivers/hid/Kconfig    |  2 +-
 drivers/hid/hid-sony.c | 24 ++++++++++++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)
drivers/hid/Kconfig +1 -1
index e76c36a..fc22f72 100644
@@ -623,7 +623,7 @@ config HID_SONY
 config SONY_FF
 	bool "Sony PS2/3 accessories force feedback support"
 	depends on HID_SONY
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	Say Y here if you have a Sony PS2/3 accessory and want to enable force
 	feedback support for it.
drivers/hid/hid-sony.c +18 -6
index 2f19b15..70a9cc5 100644
@@ -30,6 +30,7 @@
 #include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/leds.h>
+#include <linux/input/ff-memless-next.h>
 
 #include "hid-ids.h"
 
@@ -44,6 +45,7 @@
 #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER_USB | BUZZ_CONTROLLER | DUALSHOCK4_CONTROLLER_USB)
 #define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER_USB | DUALSHOCK4_CONTROLLER_USB)
 
+#define FF_UPDATE_RATE 50
 #define MAX_LEDS 4
 
 static const u8 sixaxis_rdesc_fixup[] = {
@@ -970,16 +972,25 @@ static void dualshock4_state_worker(struct work_struct *work)
 
 #ifdef CONFIG_SONY_FF
 static int sony_play_effect(struct input_dev *dev, void *data,
-			    struct ff_effect *effect)
+			    const struct mlnx_effect_command *command)
 {
 	struct hid_device *hid = input_get_drvdata(dev);
 	struct sony_sc *sc = hid_get_drvdata(hid);
+	const struct mlnx_rumble_force *rumble_force = &command->u.rumble_force;
 
-	if (effect->type != FF_RUMBLE)
-		return 0;
 
-	sc->left = effect->u.rumble.strong_magnitude / 256;
-	sc->right = effect->u.rumble.weak_magnitude / 256;
+	switch (command->cmd) {
+	case MLNX_START_RUMBLE:
+		sc->left = rumble_force->strong / 256;
+		sc->right = rumble_force->weak / 256;
+		break;
+	case MLNX_STOP_RUMBLE:
+		sc->left = 0;
+		sc->right = 0;
+		break;
+	default:
+		return -EINVAL;
+	}
 
 	schedule_work(&sc->state_worker);
 	return 0;
@@ -992,7 +1003,7 @@ static int sony_init_ff(struct hid_device *hdev)
 	struct input_dev *input_dev = hidinput->input;
 
 	input_set_capability(input_dev, EV_FF, FF_RUMBLE);
-	return input_ff_create_memless(input_dev, NULL, sony_play_effect);
+	return input_ff_create_mlnx(input_dev, NULL, sony_play_effect, FF_UPDATE_RATE);
 }
 
 #else
@@ -1150,6 +1161,7 @@ static const struct hid_device_id sony_devices[] = {
 		.driver_data = DUALSHOCK4_CONTROLLER_USB },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
 		.driver_data = DUALSHOCK4_CONTROLLER_BT },
+
 	{ }
 };
 MODULE_DEVICE_TABLE(hid, sony_devices);
Signature · 1 line
1.9.2
#33 lore raw

PATCH v2 17/24 input: Port hid-tmff to ff-memless-next

In reply to Michal Malý

Port hid-tmff to ff-memless-next

---
 drivers/hid/Kconfig    |  2 +-
 drivers/hid/hid-tmff.c | 83 ++++++++++++++++++++++++++++++--------------------
 2 files changed, 51 insertions(+), 34 deletions(-)
drivers/hid/Kconfig +1 -1
index fc22f72..ee999bc 100644
@@ -719,7 +719,7 @@ config HID_THRUSTMASTER
 config THRUSTMASTER_FF
 	bool "ThrustMaster devices force feedback support"
 	depends on HID_THRUSTMASTER
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	  Say Y here if you have a THRUSTMASTER FireStore Dual Power 2 or 3,
 	  a THRUSTMASTER Dual Trigger 3-in-1 or a THRUSTMASTER Ferrari GT
drivers/hid/hid-tmff.c +50 -33

127 lines not on this page · raw message

Signature · 6 lines
1.9.2

--
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
#34 lore raw

PATCH v2 18/24 input: Port hid-wiimote-modules to ff-memless-next

In reply to Michal Malý

Port hid-wiimote-modules to ff-memless-next

---
 drivers/hid/Kconfig               |  2 +-
 drivers/hid/hid-wiimote-modules.c | 74 ++++++++++++++++++++++++---------------
 2 files changed, 46 insertions(+), 30 deletions(-)
drivers/hid/Kconfig +1 -1
index ee999bc..d1cbad6 100644
@@ -738,7 +738,7 @@ config HID_WIIMOTE
 	depends on HID
 	depends on LEDS_CLASS
 	select POWER_SUPPLY
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	Support for Nintendo Wii and Wii U Bluetooth peripherals. Supported
 	devices are the Wii Remote and its extension devices, but also devices
drivers/hid/hid-wiimote-modules.c +45 -29

110 lines not on this page · raw message

Signature · 1 line
1.9.2
#35 lore raw

PATCH v2 19/24 input: Port hid-zpff to ff-memless-next

In reply to Michal Malý

Port hid-zpff to ff-memless-next

---
 drivers/hid/Kconfig    |  2 +-
 drivers/hid/hid-zpff.c | 30 ++++++++++++++++++++++--------
 2 files changed, 23 insertions(+), 9 deletions(-)
drivers/hid/Kconfig +1 -1
index d1cbad6..7d617a8 100644
@@ -775,7 +775,7 @@ config HID_ZEROPLUS
 config ZEROPLUS_FF
 	bool "Zeroplus based game controller force feedback support"
 	depends on HID_ZEROPLUS
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	  Say Y here if you have a Zeroplus based game controller and want
 	  to have force feedback support for it.
drivers/hid/hid-zpff.c +22 -8
index a29756c..6912500 100644
@@ -25,9 +25,12 @@
 #include <linux/input.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/input/ff-memless-next.h>
 
 #include "hid-ids.h"
 
+#define FF_UPDATE_RATE 50
+
 #ifdef CONFIG_ZEROPLUS_FF
 
 struct zpff_device {
@@ -35,10 +38,11 @@ struct zpff_device {
 };
 
 static int zpff_play(struct input_dev *dev, void *data,
-			 struct ff_effect *effect)
+			 const struct mlnx_effect_command *command)
 {
 	struct hid_device *hid = input_get_drvdata(dev);
 	struct zpff_device *zpff = data;
+	const struct mlnx_rumble_force *rumble_force = &command->u.rumble_force;
 	int left, right;
 
 	/*
@@ -47,12 +51,22 @@ static int zpff_play(struct input_dev *dev, void *data,
 	 * however it is possible that the XFX Executioner is an exception
 	 */
 
-	left = effect->u.rumble.strong_magnitude;
-	right = effect->u.rumble.weak_magnitude;
-	dbg_hid("called with 0x%04x 0x%04x\n", left, right);
-
-	left = left * 0x7f / 0xffff;
-	right = right * 0x7f / 0xffff;
+	switch (command->cmd) {
+	case MLNX_START_RUMBLE:
+		left = rumble_force->strong;
+		right = rumble_force->weak;
+		dbg_hid("called with 0x%04x 0x%04x\n", left, right);
+
+		left = left * 0x7f / 0xffff;
+		right = right * 0x7f / 0xffff;
+		break;
+	case MLNX_STOP_RUMBLE:
+		left = 0;
+		right = 0;
+		break;
+	default:
+		return -EINVAL;
+	}
 
 	zpff->report->field[2]->value[0] = left;
 	zpff->report->field[3]->value[0] = right;
@@ -83,7 +97,7 @@ static int zpff_init(struct hid_device *hid)
 
 	set_bit(FF_RUMBLE, dev->ffbit);
 
-	error = input_ff_create_memless(dev, zpff, zpff_play);
+	error = input_ff_create_mlnx(dev, zpff, zpff_play, FF_UPDATE_RATE);
 	if (error) {
 		kfree(zpff);
 		return error;
Signature · 1 line
1.9.2
#36 lore raw

PATCH v2 20/24 input: Port gamecon to ff-memless-next

In reply to Michal Malý

Port gamecon to ff-memless-next

---
 drivers/input/joystick/Kconfig   |  2 +-
 drivers/input/joystick/gamecon.c | 57 ++++++++++++++++++++++------------------
 2 files changed, 33 insertions(+), 26 deletions(-)
drivers/input/joystick/Kconfig +1 -1
index 56eb471..2dd3ba1 100644
@@ -221,7 +221,7 @@ config JOYSTICK_DB9
 config JOYSTICK_GAMECON
 	tristate "Multisystem, NES, SNES, N64, PSX joysticks and gamepads"
 	depends on PARPORT
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	  Say Y here if you have a Nintendo Entertainment System gamepad,
 	  Super Nintendo Entertainment System gamepad, Nintendo 64 gamepad,
drivers/input/joystick/gamecon.c +32 -25

94 lines not on this page · raw message

Signature · 1 line
1.9.2
#37 lore raw

PATCH v2 21/24 input: Port xpad to ff-memless-next

In reply to Michal Malý

Port xpad to ff-memless-next

---
 drivers/input/joystick/Kconfig |   2 +-
 drivers/input/joystick/xpad.c  | 125 +++++++++++++++++++++++------------------
 2 files changed, 71 insertions(+), 56 deletions(-)
drivers/input/joystick/Kconfig +1 -1
index 2dd3ba1..9f26e48 100644
@@ -294,7 +294,7 @@ config JOYSTICK_XPAD
 config JOYSTICK_XPAD_FF
 	bool "X-Box gamepad rumble support"
 	depends on JOYSTICK_XPAD && INPUT
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	---help---
 	  Say Y here if you want to take advantage of xbox 360 rumble features.
 
drivers/input/joystick/xpad.c +70 -55

152 lines not on this page · raw message

Signature · 6 lines
1.9.2

--
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
#38 lore raw

PATCH v2 22/24 input: Port hid-lg2ff to ff-memless-next

In reply to Michal Malý

* Port hid-lg2ff to ff-memless-next
* Clamp vibration magnitude to range <0x02; 0xfd> to prevent irregular shaking of the vibration motors.

---
 drivers/hid/Kconfig     |  2 +-
 drivers/hid/hid-lg2ff.c | 65 ++++++++++++++++++++++++++++++++++---------------
 2 files changed, 47 insertions(+), 20 deletions(-)
drivers/hid/Kconfig +1 -1
index 7d617a8..8889b7a 100644
@@ -372,7 +372,7 @@ config LOGITECH_FF
 config LOGIRUMBLEPAD2_FF
 	bool "Logitech force feedback support (variant 2)"
 	depends on HID_LOGITECH
-	select INPUT_FF_MEMLESS
+	select INPUT_FF_MEMLESS_NEXT
 	help
 	  Say Y here if you want to enable force feedback support for:
 	  - Logitech RumblePad
drivers/hid/hid-lg2ff.c +46 -19

95 lines not on this page · raw message

Signature · 1 line
1.9.2
#39 lore raw

PATCH v2 23/24 input: Port hid-lg4ff to ff-memless-next

In reply to Michal Malý

Port hid-lg4ff to ff-memless-next

---
 drivers/hid/Kconfig     |  2 +-
 drivers/hid/hid-lg4ff.c | 93 ++++++++++++++++++++++++++++++-------------------
 2 files changed, 59 insertions(+), 36 deletions(-)
drivers/hid/Kconfig +1 -1
index 8889b7a..5e6aa8e 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 +58 -35

130 lines not on this page · raw message

Signature · 1 line
1.9.2
#40 lore raw

PATCH v2 24/24 input: Replace ff-memless with ff-memless-next

In reply to Michal Malý

Replace ff-memless with ff-memless-next

---
 drivers/input/Kconfig      |  13 +-
 drivers/input/Makefile     |   1 -
 drivers/input/ff-memless.c | 547 ---------------------------------------------
 include/linux/input.h      |   3 -
 4 files changed, 1 insertion(+), 563 deletions(-)
 delete mode 100644 drivers/input/ff-memless.c
drivers/input/Kconfig +1 -12
index 3780962..061ae3c 100644
@@ -25,7 +25,7 @@ config INPUT
 
 if INPUT
 
-config INPUT_FF_MEMLESS
+config INPUT_FF_MEMLESS_NEXT
 	tristate "Support for memoryless force-feedback devices"
 	help
 	  Say Y here if you have memoryless force-feedback input device
@@ -36,17 +36,6 @@ config INPUT_FF_MEMLESS
 	  If unsure, say N.
 
 	  To compile this driver as a module, choose M here: the
-	  module will be called ff-memless.
-
-config INPUT_FF_MEMLESS_NEXT
-	tristate "New version of support for memoryless force-feedback devices"
-	help
-	  Say Y here to enable a new version of support for 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.
 
 config INPUT_POLLDEV
drivers/input/Makefile +0 -1
index b4f11f5..f7ae055 100644
@@ -7,7 +7,6 @@
 obj-$(CONFIG_INPUT)		+= input-core.o
 input-core-y := input.o input-compat.o input-mt.o ff-core.o
 
-obj-$(CONFIG_INPUT_FF_MEMLESS)	+= ff-memless.o
 obj-$(CONFIG_INPUT_FF_MEMLESS_NEXT)	+= ff-memless-next.o
 obj-$(CONFIG_INPUT_POLLDEV)	+= input-polldev.o
 obj-$(CONFIG_INPUT_SPARSEKMAP)	+= sparse-keymap.o
drivers/input/ff-memless.c deleted +0 -547

547 lines not on this page · raw message

include/linux/input.h +0 -3
index 82ce323..0c6c3f1 100644
@@ -528,7 +528,4 @@ int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code,
 int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, struct file *file);
 int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file);
 
-int input_ff_create_memless(struct input_dev *dev, void *data,
-		int (*play_effect)(struct input_dev *, void *, struct ff_effect *));
-
 #endif
Signature · 1 line
1.9.2