linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel
@ 2013-11-06 19:30 Simon Wood
  2013-11-06 19:30 ` [PATCH 2/5] HID:hid-lg4ff: Switch autocentering off when strength is set to zero Simon Wood
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Simon Wood @ 2013-11-06 19:30 UTC (permalink / raw)
  To: linux-input
  Cc: Jiri Kosina, linux-kernel, simon, Elias Vanderstuyft,
	Michal Malý

Adjust the scaling and lineartity to match that of the Windows
driver (from MOMO testing).

Reported-by: Elias Vanderstuyft <elias.vds@gmail.com>
Signed-off-by: Simon Wood <simon@mungewell.org>
---
 drivers/hid/hid-lg4ff.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 8782fe1..530fcd19 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -218,12 +218,21 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
 	struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
 	struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
 	__s32 *value = report->field[0]->value;
+	__u32 expand_a, expand_b;
+
+	if (magnitude <= 0xaaaa) {
+		expand_a = 0x0c * magnitude;
+		expand_b = 0x80 * magnitude;
+	} else {
+		expand_a = (0x0c * 0xaaaa) + 0x06 * (magnitude - 0xaaaa);
+		expand_b = (0x80 * 0xaaaa) + 0xff * (magnitude - 0xaaaa);
+	}
 
 	value[0] = 0xfe;
 	value[1] = 0x0d;
-	value[2] = magnitude >> 13;
-	value[3] = magnitude >> 13;
-	value[4] = magnitude >> 8;
+	value[2] = expand_a / 0xaaaa;
+	value[3] = expand_a / 0xaaaa;
+	value[4] = expand_b / 0xaaaa;
 	value[5] = 0x00;
 	value[6] = 0x00;
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] HID:hid-lg4ff: Switch autocentering off when strength is set to zero.
  2013-11-06 19:30 [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel Simon Wood
@ 2013-11-06 19:30 ` Simon Wood
  2013-11-06 19:30 ` [PATCH 3/5] HID:hid-lg4ff: ensure ConstantForce is disabled when set to 0 Simon Wood
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Simon Wood @ 2013-11-06 19:30 UTC (permalink / raw)
  To: linux-input
  Cc: Jiri Kosina, linux-kernel, simon, Elias Vanderstuyft,
	Michal Malý

When the autocenter is set to zero, this patch issues a command to
totally disable the autocenter - this results in less resistance
in the wheel.

Reported-by: Elias Vanderstuyft <elias.vds@gmail.com>
Signed-off-by: Simon Wood <simon@mungewell.org>
---
 drivers/hid/hid-lg4ff.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 530fcd19..49f6cc0 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -220,6 +220,20 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
 	__s32 *value = report->field[0]->value;
 	__u32 expand_a, expand_b;
 
+	/* De-activate Auto-Center */
+	if (magnitude == 0) {
+		value[0] = 0xf5;
+		value[1] = 0x00;
+		value[2] = 0x00;
+		value[3] = 0x00;
+		value[4] = 0x00;
+		value[5] = 0x00;
+		value[6] = 0x00;
+
+		hid_hw_request(hid, report, HID_REQ_SET_REPORT);
+		return;
+	}
+
 	if (magnitude <= 0xaaaa) {
 		expand_a = 0x0c * magnitude;
 		expand_b = 0x80 * magnitude;
@@ -237,6 +251,17 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
 	value[6] = 0x00;
 
 	hid_hw_request(hid, report, HID_REQ_SET_REPORT);
+
+	/* Activate Auto-Center */
+	value[0] = 0x14;
+	value[1] = 0x00;
+	value[2] = 0x00;
+	value[3] = 0x00;
+	value[4] = 0x00;
+	value[5] = 0x00;
+	value[6] = 0x00;
+
+	hid_hw_request(hid, report, HID_REQ_SET_REPORT);
 }
 
 /* Sends autocentering command compatible with Formula Force EX */
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] HID:hid-lg4ff: ensure ConstantForce is disabled when set to 0
  2013-11-06 19:30 [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel Simon Wood
  2013-11-06 19:30 ` [PATCH 2/5] HID:hid-lg4ff: Switch autocentering off when strength is set to zero Simon Wood
@ 2013-11-06 19:30 ` Simon Wood
  2013-11-06 19:30 ` [PATCH 4/5] HID:hid-lg4ff: Initialize device properties before we touch autocentering Simon Wood
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Simon Wood @ 2013-11-06 19:30 UTC (permalink / raw)
  To: linux-input
  Cc: Jiri Kosina, linux-kernel, simon, Elias Vanderstuyft,
	Michal Malý

When 'Constant Force' is set to 0 it is not turned off completely,
the wheel feels 'heavy'. This patch issues the '13 00..' command
to ensure that the force in slot 1 (the Constant Force) is
deactivated.

Reported-by: Elias Vanderstuyft <elias.vds@gmail.com>
Signed-off-by: Simon Wood <simon@mungewell.org>
---
 drivers/hid/hid-lg4ff.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 49f6cc0..5d140b7 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -196,6 +196,21 @@ static int hid_lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *e
 	case FF_CONSTANT:
 		x = effect->u.ramp.start_level + 0x80;	/* 0x80 is no force */
 		CLAMP(x);
+
+		if (x == 0x80) {
+			/* De-activate force in slot-1*/
+			value[0] = 0x13;
+			value[1] = 0x00;
+			value[2] = 0x00;
+			value[3] = 0x00;
+			value[4] = 0x00;
+			value[5] = 0x00;
+			value[6] = 0x00;
+
+			hid_hw_request(hid, report, HID_REQ_SET_REPORT);
+			return 0;
+		}
+
 		value[0] = 0x11;	/* Slot 1 */
 		value[1] = 0x08;
 		value[2] = x;
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] HID:hid-lg4ff: Initialize device properties before we touch autocentering.
  2013-11-06 19:30 [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel Simon Wood
  2013-11-06 19:30 ` [PATCH 2/5] HID:hid-lg4ff: Switch autocentering off when strength is set to zero Simon Wood
  2013-11-06 19:30 ` [PATCH 3/5] HID:hid-lg4ff: ensure ConstantForce is disabled when set to 0 Simon Wood
@ 2013-11-06 19:30 ` Simon Wood
  2013-11-06 19:30 ` [PATCH 5/5] HID:hid-lg4ff: Correct Auto-center strength for wheels other than MOMO and MOMO2 Simon Wood
  2013-11-08 13:14 ` [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel Jiri Kosina
  4 siblings, 0 replies; 7+ messages in thread
From: Simon Wood @ 2013-11-06 19:30 UTC (permalink / raw)
  To: linux-input
  Cc: Jiri Kosina, linux-kernel, simon, Elias Vanderstuyft,
	Michal Malý

Re-arrange code slightly to ensure that device properties are configured
before calling auto-center command.

Reported-by: Michal Malý <madcatxster@prifuk.cz>
Signed-off-by: Simon Wood <simon@mungewell.org>
---
 drivers/hid/hid-lg4ff.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 5d140b7..5492809 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -589,17 +589,6 @@ int lg4ff_init(struct hid_device *hid)
 	if (error)
 		return error;
 
-	/* Check if autocentering is available and
-	 * set the centering force to zero by default */
-	if (test_bit(FF_AUTOCENTER, dev->ffbit)) {
-		if (rev_maj == FFEX_REV_MAJ && rev_min == FFEX_REV_MIN)	/* Formula Force EX expects different autocentering command */
-			dev->ff->set_autocenter = hid_lg4ff_set_autocenter_ffex;
-		else
-			dev->ff->set_autocenter = hid_lg4ff_set_autocenter_default;
-
-		dev->ff->set_autocenter(dev, 0);
-	}
-
 	/* Get private driver data */
 	drv_data = hid_get_drvdata(hid);
 	if (!drv_data) {
@@ -620,6 +609,17 @@ int lg4ff_init(struct hid_device *hid)
 	entry->max_range = lg4ff_devices[i].max_range;
 	entry->set_range = lg4ff_devices[i].set_range;
 
+	/* Check if autocentering is available and
+	 * set the centering force to zero by default */
+	if (test_bit(FF_AUTOCENTER, dev->ffbit)) {
+		if (rev_maj == FFEX_REV_MAJ && rev_min == FFEX_REV_MIN)	/* Formula Force EX expects different autocentering command */
+			dev->ff->set_autocenter = hid_lg4ff_set_autocenter_ffex;
+		else
+			dev->ff->set_autocenter = hid_lg4ff_set_autocenter_default;
+
+		dev->ff->set_autocenter(dev, 0);
+	}
+
 	/* Create sysfs interface */
 	error = device_create_file(&hid->dev, &dev_attr_range);
 	if (error)
-- 
1.8.1.2

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] HID:hid-lg4ff: Correct Auto-center strength for wheels other than MOMO and MOMO2
  2013-11-06 19:30 [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel Simon Wood
                   ` (2 preceding siblings ...)
  2013-11-06 19:30 ` [PATCH 4/5] HID:hid-lg4ff: Initialize device properties before we touch autocentering Simon Wood
@ 2013-11-06 19:30 ` Simon Wood
  2013-11-08 13:14 ` [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel Jiri Kosina
  4 siblings, 0 replies; 7+ messages in thread
From: Simon Wood @ 2013-11-06 19:30 UTC (permalink / raw)
  To: linux-input
  Cc: Jiri Kosina, linux-kernel, simon, Elias Vanderstuyft,
	Michal Malý

The MOMO and MOMO2 wheels have a slightly different autocenter command,
and accept values in the range 0..F (rather than 0..7 for the other wheels).

This patch uses the product ID to determine how to compute the strength.

Signed-off-by: Simon Wood <simon@mungewell.org>
---
 drivers/hid/hid-lg4ff.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 5492809..befe0e3 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -234,6 +234,20 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
 	struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
 	__s32 *value = report->field[0]->value;
 	__u32 expand_a, expand_b;
+	struct lg4ff_device_entry *entry;
+	struct lg_drv_data *drv_data;
+
+	drv_data = hid_get_drvdata(hid);
+	if (!drv_data) {
+		hid_err(hid, "Private driver data not found!\n");
+		return;
+	}
+
+	entry = drv_data->device_props;
+	if (!entry) {
+		hid_err(hid, "Device properties not found!\n");
+		return;
+	}
 
 	/* De-activate Auto-Center */
 	if (magnitude == 0) {
@@ -257,6 +271,16 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
 		expand_b = (0x80 * 0xaaaa) + 0xff * (magnitude - 0xaaaa);
 	}
 
+	/* Adjust for non-MOMO wheels */
+	switch (entry->product_id) {
+	case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL:
+	case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2:
+		break;
+	default:
+		expand_a = expand_a >> 1;
+		break;
+	}
+
 	value[0] = 0xfe;
 	value[1] = 0x0d;
 	value[2] = expand_a / 0xaaaa;
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel
  2013-11-06 19:30 [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel Simon Wood
                   ` (3 preceding siblings ...)
  2013-11-06 19:30 ` [PATCH 5/5] HID:hid-lg4ff: Correct Auto-center strength for wheels other than MOMO and MOMO2 Simon Wood
@ 2013-11-08 13:14 ` Jiri Kosina
  2013-11-08 15:54   ` simon
  4 siblings, 1 reply; 7+ messages in thread
From: Jiri Kosina @ 2013-11-08 13:14 UTC (permalink / raw)
  To: Simon Wood
  Cc: linux-input, linux-kernel, Elias Vanderstuyft, Michal Malý

On Wed, 6 Nov 2013, Simon Wood wrote:

> Adjust the scaling and lineartity to match that of the Windows
> driver (from MOMO testing).
> 
> Reported-by: Elias Vanderstuyft <elias.vds@gmail.com>
> Signed-off-by: Simon Wood <simon@mungewell.org>

I have applied the series, thanks.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel
  2013-11-08 13:14 ` [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel Jiri Kosina
@ 2013-11-08 15:54   ` simon
  0 siblings, 0 replies; 7+ messages in thread
From: simon @ 2013-11-08 15:54 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Simon Wood, linux-input, linux-kernel, Elias Vanderstuyft,
	"Michal Malý"

> On Wed, 6 Nov 2013, Simon Wood wrote:
>
>> Adjust the scaling and lineartity to match that of the Windows
>> driver (from MOMO testing).
>>
>> Reported-by: Elias Vanderstuyft <elias.vds@gmail.com>
>> Signed-off-by: Simon Wood <simon@mungewell.org>
>
> I have applied the series, thanks.

Thanks to all involved.
Simon


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-11-08 15:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-06 19:30 [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel Simon Wood
2013-11-06 19:30 ` [PATCH 2/5] HID:hid-lg4ff: Switch autocentering off when strength is set to zero Simon Wood
2013-11-06 19:30 ` [PATCH 3/5] HID:hid-lg4ff: ensure ConstantForce is disabled when set to 0 Simon Wood
2013-11-06 19:30 ` [PATCH 4/5] HID:hid-lg4ff: Initialize device properties before we touch autocentering Simon Wood
2013-11-06 19:30 ` [PATCH 5/5] HID:hid-lg4ff: Correct Auto-center strength for wheels other than MOMO and MOMO2 Simon Wood
2013-11-08 13:14 ` [PATCH 1/5] HID:hid-lg4ff: Scale autocentering force properly on Logitech wheel Jiri Kosina
2013-11-08 15:54   ` simon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).