From: Elias Vanderstuyft <elias.vds@gmail.com> To: Jiri Kosina <jkosina@suse.cz> Cc: "Elias Vanderstuyft" <elias.vds@gmail.com>, "Edgar Simo-Serra" <bobbens@gmail.com>, "Michal Malý" <madcatxster@devoid-pointer.net>, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: lg2ff: add rumble magnitude clamping quirk Date: Tue, 8 Apr 2014 15:06:07 +0200 [thread overview] Message-ID: <1396962367-6469-1-git-send-email-elias.vds@gmail.com> (raw) If a magnitude in the output report is lower than 2, i.e. 1 or 0, the corresponding rumble motor shakes irregularly, instead of being turned (almost) off like when magnitude 2 is used. On the other hand, if a magnitude is higher than 0xfd, i.e 0xfe or 0xff, the corresponding rumble motor shakes irregularly with a rotation speed lower than when magnitude 0xfd is used. >From 0x02 to 0xfd, the device behaves well: a monotonic increase of rotation speed. This applies to both weak and strong rumble motor types. This patch fixes this issue by clamping magnitudes from 0x02 to 0xfd. This behaviour is observed on the Formula Vibration wheel (ca04). However it's not present on the Wingman Rumblepad (c20a) device, yet the clamping has no effect on the haptic side, so that special case handling is not needed. Discussion on http://www.spinics.net/lists/linux-input/msg30711.html Note: The same thing appears to happen in the Windows Logitech driver, except the max clamping bound is not 0xfd, but 0xfe. Experimentally, I proved this to be wrong. Tested-by: Hendrik Iben <hendrik_iben@web.de> Signed-off-by: Elias Vanderstuyft <elias.vds@gmail.com> Cc: Edgar Simo-Serra <bobbens@gmail.com> Cc: Michal Malý <madcatxster@devoid-pointer.net> Cc: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/hid/hid-lg2ff.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c index 0e3fb1a..e180e1e 100644 --- a/drivers/hid/hid-lg2ff.c +++ b/drivers/hid/hid-lg2ff.c @@ -38,12 +38,17 @@ static int play_effect(struct input_dev *dev, void *data, struct lg2ff_device *lg2ff = data; int weak, strong; +#define CLAMP_QUIRK(x) do { if (x < 2) x = 2; else if (x > 0xfd) x = 0xfd; } \ + while (0) + strong = effect->u.rumble.strong_magnitude; weak = effect->u.rumble.weak_magnitude; if (weak || strong) { weak = weak * 0xff / 0xffff; strong = strong * 0xff / 0xffff; + CLAMP_QUIRK(weak); + CLAMP_QUIRK(strong); lg2ff->report->field[0]->value[0] = 0x51; lg2ff->report->field[0]->value[2] = weak; -- 1.8.3.1
WARNING: multiple messages have this Message-ID (diff)
From: Elias Vanderstuyft <elias.vds@gmail.com> To: Jiri Kosina <jkosina@suse.cz> Cc: "Elias Vanderstuyft" <elias.vds@gmail.com>, "Edgar Simo-Serra" <bobbens@gmail.com>, "Michal Malý" <madcatxster@devoid-pointer.net>, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: lg2ff: add rumble magnitude clamping quirk Date: Tue, 8 Apr 2014 15:06:07 +0200 [thread overview] Message-ID: <1396962367-6469-1-git-send-email-elias.vds@gmail.com> (raw) If a magnitude in the output report is lower than 2, i.e. 1 or 0, the corresponding rumble motor shakes irregularly, instead of being turned (almost) off like when magnitude 2 is used. On the other hand, if a magnitude is higher than 0xfd, i.e 0xfe or 0xff, the corresponding rumble motor shakes irregularly with a rotation speed lower than when magnitude 0xfd is used. From 0x02 to 0xfd, the device behaves well: a monotonic increase of rotation speed. This applies to both weak and strong rumble motor types. This patch fixes this issue by clamping magnitudes from 0x02 to 0xfd. This behaviour is observed on the Formula Vibration wheel (ca04). However it's not present on the Wingman Rumblepad (c20a) device, yet the clamping has no effect on the haptic side, so that special case handling is not needed. Discussion on http://www.spinics.net/lists/linux-input/msg30711.html Note: The same thing appears to happen in the Windows Logitech driver, except the max clamping bound is not 0xfd, but 0xfe. Experimentally, I proved this to be wrong. Tested-by: Hendrik Iben <hendrik_iben@web.de> Signed-off-by: Elias Vanderstuyft <elias.vds@gmail.com> Cc: Edgar Simo-Serra <bobbens@gmail.com> Cc: Michal Malý <madcatxster@devoid-pointer.net> Cc: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/hid/hid-lg2ff.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c index 0e3fb1a..e180e1e 100644 --- a/drivers/hid/hid-lg2ff.c +++ b/drivers/hid/hid-lg2ff.c @@ -38,12 +38,17 @@ static int play_effect(struct input_dev *dev, void *data, struct lg2ff_device *lg2ff = data; int weak, strong; +#define CLAMP_QUIRK(x) do { if (x < 2) x = 2; else if (x > 0xfd) x = 0xfd; } \ + while (0) + strong = effect->u.rumble.strong_magnitude; weak = effect->u.rumble.weak_magnitude; if (weak || strong) { weak = weak * 0xff / 0xffff; strong = strong * 0xff / 0xffff; + CLAMP_QUIRK(weak); + CLAMP_QUIRK(strong); lg2ff->report->field[0]->value[0] = 0x51; lg2ff->report->field[0]->value[2] = weak; -- 1.8.3.1
next reply other threads:[~2014-04-08 13:11 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-04-08 13:06 Elias Vanderstuyft [this message] 2014-04-08 13:06 ` [PATCH] HID: lg2ff: add rumble magnitude clamping quirk Elias Vanderstuyft 2014-04-09 9:19 ` Elias Vanderstuyft 2014-04-09 9:24 ` Jiri Kosina
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1396962367-6469-1-git-send-email-elias.vds@gmail.com \ --to=elias.vds@gmail.com \ --cc=bobbens@gmail.com \ --cc=jkosina@suse.cz \ --cc=linux-input@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=madcatxster@devoid-pointer.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.