From: Desmond Lim <peckishrine@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Desmond Lim <peckishrine@gmail.com>,
Kinglong Mee <kinglongmee@gmail.com>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: [PATCH v2] HID: sigmamicro: Fix modifier keys for SiGma Micro based keyboards
Date: Tue, 7 Dec 2021 21:36:00 +0800 [thread overview]
Message-ID: <20211207133603.4947-1-peckishrine@gmail.com> (raw)
SIGMACHIP USB Keyboard (1c4f:0059) has a problem where all the
modifier keys mapped to Shift_L.
Fix the report descriptor to make modifier keys work as expected.
Co-developed-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Desmond Lim <peckishrine@gmail.com>
---
Changes since v1:
- Update commit message
- Correct Kconfig dependency
---
drivers/hid/Kconfig | 10 ++++++++
drivers/hid/Makefile | 1 +
drivers/hid/hid-ids.h | 1 +
drivers/hid/hid-sigmamicro.c | 45 ++++++++++++++++++++++++++++++++++++
4 files changed, 57 insertions(+)
create mode 100644 drivers/hid/hid-sigmamicro.c
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 9f5435b55949..5b76c56bf9a4 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -970,6 +970,16 @@ config HID_SEMITEK
- Woo-dy
- X-Bows Nature/Knight
+config HID_SIGMAMICRO
+ tristate "SiGma Micro based keyboards"
+ depends on USB_HID
+ help
+ Support for keyboards that use the SiGma Micro (a.k.a SigmaChip) IC.
+
+ Supported devices:
+ - Landslides KR-700
+ - Rapoo V500
+
config HID_SONY
tristate "Sony PS2/3/4 accessories"
depends on USB_HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 55a6fa3eca5a..89ea7fafb66b 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -108,6 +108,7 @@ obj-$(CONFIG_HID_RMI) += hid-rmi.o
obj-$(CONFIG_HID_SAITEK) += hid-saitek.o
obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
obj-$(CONFIG_HID_SEMITEK) += hid-semitek.o
+obj-$(CONFIG_HID_SIGMAMICRO) += hid-sigmamicro.o
obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o
obj-$(CONFIG_HID_SONY) += hid-sony.o
obj-$(CONFIG_HID_SPEEDLINK) += hid-speedlink.o
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 96a455921c67..279410bc8fce 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -1083,6 +1083,7 @@
#define USB_VENDOR_ID_SIGMA_MICRO 0x1c4f
#define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD 0x0002
+#define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD2 0x0059
#define USB_VENDOR_ID_SIGMATEL 0x066F
#define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780
diff --git a/drivers/hid/hid-sigmamicro.c b/drivers/hid/hid-sigmamicro.c
new file mode 100644
index 000000000000..eb34d6198083
--- /dev/null
+++ b/drivers/hid/hid-sigmamicro.c
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * HID driver for SiGma Micro based keyboards
+ *
+ * Copyright (c) 2016 Kinglong Mee
+ * Copyright (c) 2021 Desmond Lim
+ */
+
+#include <linux/device.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+
+#include "hid-ids.h"
+
+static __u8 *sm_report_fixup(struct hid_device *hdev, __u8 *rdesc,
+ unsigned int *rsize)
+{
+ switch (hdev->product) {
+ case USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD2:
+ if (*rsize == 167 && rdesc[98] == 0x81 && rdesc[99] == 0x00) {
+ hid_info(hdev, "Fixing up SiGma Micro report descriptor\n");
+ rdesc[99] = 0x02;
+ }
+ break;
+ }
+ return rdesc;
+}
+
+static const struct hid_device_id sm_devices[] = {
+ { HID_USB_DEVICE(USB_VENDOR_ID_SIGMA_MICRO, USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD2) },
+ { }
+};
+MODULE_DEVICE_TABLE(hid, sm_devices);
+
+static struct hid_driver sm_driver = {
+ .name = "sigmamicro",
+ .id_table = sm_devices,
+ .report_fixup = sm_report_fixup,
+};
+module_hid_driver(sm_driver);
+
+MODULE_AUTHOR("Kinglong Mee <kinglongmee@gmail.com>");
+MODULE_AUTHOR("Desmond Lim <peckishrine@gmail.com>");
+MODULE_DESCRIPTION("SiGma Micro HID driver");
+MODULE_LICENSE("GPL");
base-commit: 740bebf42104d2f082514b1545a14056f3b1b56c
--
2.30.2
next reply other threads:[~2021-12-07 13:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-07 13:36 Desmond Lim [this message]
2021-12-30 15:31 ` Desmond Lim
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=20211207133603.4947-1-peckishrine@gmail.com \
--to=peckishrine@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=kinglongmee@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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®