From: "benjamin.tissoires" <benjamin.tissoires@gmail.com>
To: "benjamin.tissoires" <benjamin.tissoires@gmail.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Henrik Rydberg <rydberg@euromail.se>,
Jiri Kosina <jkosina@suse.cz>, Stephane Chatty <chatty@enac.fr>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3] HID: autoload hid-multitouch as needed
Date: Wed, 28 Mar 2012 16:33:18 +0200 [thread overview]
Message-ID: <1332945198-2518-1-git-send-email-benjamin.tissoires@gmail.com> (raw)
From: Benjamin Tissoires <benjamin.tissoires@enac.fr>
When the generic hid parsing of the report descriptors in hid-core
detects that the device contains the field ContactID, the device should
be handled by hid-multitouch, and hid-core should release it.
This patch implements a temporary fix for hid-core to automatically
call the loading of hid-multitouch. A better solution would involve
userspace.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
---
Hi guys,
This is the v3 of the patch.
Changes since v2:
- make the working queue global to the module. As noted by Henrik,
there is no need to have a per-device working queue.
- removed the boolean that tells if the working queue has been initialized
and filled: we have only one wq that is initialized at the loading of the
module. I didn't put any threading guards: as far as I understood, working
queues are thread safe.
There is still one problem: this works for hotplugged devices. Coldplugged
ones (before booting then) are not loading hid-multitouch on my computer.
I don't think the previous implementation worked either. However, I don't
think it's a big issue as we may ask end-user to add hid-multitouch in this
case in their /etc/modules-load.d/.
Cheers,
Benjamin
drivers/hid/hid-core.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 990fe19..f694aa1 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1210,6 +1210,39 @@ static struct bin_attribute dev_bin_attr_report_desc = {
.size = HID_MAX_DESCRIPTOR_SIZE,
};
+#if defined(CONFIG_MODULES) && defined(MODULE)
+/* This is a temporary fix to make hid-multitouch loadable from
+ * the kernel before we come up with more robust attitude
+ * (with userspace involvement).
+ * In case we detect a multitouch device through the parsing of
+ * hid-core, we request hid-multitouch to be loaded. */
+static struct work_struct request_hid_mt_module_wk;
+
+static void hid_request_hid_mt_module_async(struct work_struct *work)
+{
+ request_module("hid-multitouch");
+}
+
+static inline void hid_request_hid_mt_module(void)
+{
+ schedule_work(&request_hid_mt_module_wk);
+}
+
+static inline void hid_flush_request_modules(void)
+{
+ flush_work_sync(&request_hid_mt_module_wk);
+}
+
+static inline void hid_init_request_modules(void)
+{
+ INIT_WORK(&request_hid_mt_module_wk, hid_request_hid_mt_module_async);
+}
+#else
+#define hid_request_hid_mt_module()
+#define hid_flush_request_modules()
+#define hid_init_request_modules()
+#endif /* CONFIG_MODULES */
+
int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
{
static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
@@ -1235,7 +1268,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
connect_mask & HID_CONNECT_HIDINPUT_FORCE))
hdev->claimed |= HID_CLAIMED_INPUT;
if (hdev->quirks & HID_QUIRK_MULTITOUCH) {
- /* this device should be handled by hid-multitouch, skip it */
+ /* this device should be handled by hid-multitouch, request
+ * for hid-multitouch to be loaded and leave the device to it */
+ hid_request_hid_mt_module();
return -ENODEV;
}
@@ -2210,6 +2245,8 @@ static int __init hid_init(void)
hid_debug_init();
+ hid_init_request_modules();
+
return 0;
err_bus:
bus_unregister(&hid_bus_type);
@@ -2219,6 +2256,7 @@ err:
static void __exit hid_exit(void)
{
+ hid_flush_request_modules();
hid_debug_exit();
hidraw_exit();
bus_unregister(&hid_bus_type);
--
1.7.7.6
next reply other threads:[~2012-03-28 14:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-28 14:33 benjamin.tissoires [this message]
2012-03-30 17:41 ` Henrik Rydberg
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=1332945198-2518-1-git-send-email-benjamin.tissoires@gmail.com \
--to=benjamin.tissoires@gmail.com \
--cc=chatty@enac.fr \
--cc=dmitry.torokhov@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rydberg@euromail.se \
/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
all inboxes | Powered by JetHome®