From: Jonathan Denose <jdenose@google.com>
To: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Jonathan Corbet <corbet@lwn.net>,
Henrik Rydberg <rydberg@bitmath.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, Angela Czubak <aczubak@google.com>,
"Sean O'Brien" <seobrien@google.com>,
Jonathan Denose <jdenose@google.com>
Subject: [PATCH 08/11] HID: haptic: add functions handling events
Date: Mon, 14 Jul 2025 15:09:41 +0000 [thread overview]
Message-ID: <20250714-support-forcepads-v1-8-71c7c05748c9@google.com> (raw)
In-Reply-To: <20250714-support-forcepads-v1-0-71c7c05748c9@google.com>
From: Angela Czubak <aczubak@google.com>
Implement hid_haptic_handle_press_release() which generates haptic feedback
as well as saves the pressed state of the haptic device.
Add functions to increase and reset the state of the pressure detected by
the device.
Signed-off-by: Angela Czubak <aczubak@google.com>
Co-developed-by: Jonathan Denose <jdenose@google.com>
Signed-off-by: Jonathan Denose <jdenose@google.com>
---
drivers/hid/hid-haptic.c | 20 +++++++++++++++++++-
drivers/hid/hid-haptic.h | 4 ++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index 923b685f0e1e81b7f95567b11209af264c522373..760dd1d70583489c07e199943ebba361d347bfa4 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -50,8 +50,13 @@ EXPORT_SYMBOL_GPL(hid_haptic_feature_mapping);
bool hid_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
struct hid_input *hi, struct hid_field *field)
{
- if (field->unit == HID_UNIT_GRAM || field->unit == HID_UNIT_NEWTON)
+ if (field->unit == HID_UNIT_GRAM || field->unit == HID_UNIT_NEWTON) {
+ haptic->force_logical_minimum = field->logical_minimum;
+ haptic->force_physical_minimum = field->physical_minimum;
+ haptic->force_resolution = input_abs_get_res(hi->input,
+ ABS_MT_PRESSURE);
return true;
+ }
return false;
}
EXPORT_SYMBOL_GPL(hid_haptic_check_pressure_unit);
@@ -508,3 +513,16 @@ int hid_haptic_init(struct hid_device *hdev,
return ret;
}
EXPORT_SYMBOL_GPL(hid_haptic_init);
+
+void hid_haptic_pressure_reset(struct hid_haptic_device *haptic)
+{
+ haptic->pressure_sum = 0;
+}
+EXPORT_SYMBOL_GPL(hid_haptic_pressure_reset);
+
+void hid_haptic_pressure_increase(struct hid_haptic_device *haptic,
+ __s32 pressure)
+{
+ haptic->pressure_sum += pressure;
+}
+EXPORT_SYMBOL_GPL(hid_haptic_pressure_increase);
diff --git a/drivers/hid/hid-haptic.h b/drivers/hid/hid-haptic.h
index 9aa910579d09206a2a882a5f708efd8620428f78..0a34b0c6d706a985630962acc41f7a8eb73cd343 100644
--- a/drivers/hid/hid-haptic.h
+++ b/drivers/hid/hid-haptic.h
@@ -73,3 +73,7 @@ int hid_haptic_input_configured(struct hid_device *hdev,
struct hid_haptic_device *haptic,
struct hid_input *hi);
int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device **haptic_ptr);
+void hid_haptic_handle_press_release(struct hid_haptic_device *haptic);
+void hid_haptic_pressure_reset(struct hid_haptic_device *haptic);
+void hid_haptic_pressure_increase(struct hid_haptic_device *haptic,
+ __s32 pressure);
--
2.50.0.727.gbf7dc18ff4-goog
next prev parent reply other threads:[~2025-07-14 15:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 15:09 [PATCH 00/11] HID: Implement haptic forcepad support Jonathan Denose
2025-07-14 15:09 ` [PATCH 01/11] HID: add haptics page defines Jonathan Denose
2025-07-14 15:09 ` [PATCH 02/11] Input: add FF_HID effect type Jonathan Denose
2025-07-14 15:09 ` [PATCH 03/11] Input: add INPUT_PROP_HAPTIC_TOUCHPAD Jonathan Denose
2025-07-14 15:09 ` [PATCH 04/11] HID: haptic: introduce hid_haptic_device Jonathan Denose
2025-07-14 15:09 ` [PATCH 05/11] HID: input: allow mapping of haptic output Jonathan Denose
2025-07-14 15:09 ` [PATCH 06/11] HID: haptic: initialize haptic device Jonathan Denose
2025-07-14 15:09 ` [PATCH 07/11] HID: input: calculate resolution for pressure Jonathan Denose
2025-07-14 15:09 ` Jonathan Denose [this message]
2025-07-14 15:09 ` [PATCH 09/11] Input: MT - add INPUT_MT_TOTAL_FORCE flags Jonathan Denose
2025-07-14 15:09 ` [PATCH 10/11] HID: haptic: add hid_haptic_switch_mode Jonathan Denose
2025-07-14 15:09 ` [PATCH 11/11] HID: multitouch: add haptic multitouch support Jonathan Denose
2025-07-15 11:35 ` kernel test robot
2025-07-17 18:43 ` Jonathan Denose
2025-07-17 23:59 ` Philip Li
2025-07-21 16:06 ` Jonathan Denose
2025-07-31 2:55 ` Oliver Sang
2025-08-01 21:30 ` Jonathan Denose
2025-07-23 19:59 ` [PATCH 00/11] HID: Implement haptic forcepad support Jonathan Denose
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=20250714-support-forcepads-v1-8-71c7c05748c9@google.com \
--to=jdenose@google.com \
--cc=aczubak@google.com \
--cc=bentiss@kernel.org \
--cc=corbet@lwn.net \
--cc=dmitry.torokhov@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rydberg@bitmath.org \
--cc=seobrien@google.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).