mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID updates from Jiri Kosina: - support for Nintendo Switch Pro Controllers and Joy-Cons (Daniel J. Ogorchock) - support for new revision of the NitroKey U2F device firmware (Andrej Shadura) - LED handling improvements for Sony Playstation5 controllers (Roderick Colenbrander) - support for Apple 2021 Magic Keyboard (Alex Henrie) - other assorted code cleanups and new device ID additions * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (41 commits) HID: nintendo: fix -Werror build HID: playstation: require multicolor LED functionality HID: u2fzero: properly handle timeouts in usb_submit_urb HID: u2fzero: clarify error check and length calculations HID: u2fzero: Support NitroKey U2F revision of the device HID: wacom: Make use of the helper function devm_add_action_or_reset() HID: wacom: Shrink critical section in `wacom_add_shared_data` HID: nintendo: prevent needless queueing of the rumble worker HID: nintendo: ratelimit subcommands and rumble HID: nintendo: improve rumble performance and stability HID: nintendo: add IMU support HID: nintendo: add support for reading user calibration HID: nintendo: add support for charging grip HID: nintendo: set controller uniq to MAC HID: nintendo: reduce device removal subcommand errors HID: nintendo: patch hw version for userspace HID mappings HID: nintendo: send subcommands after receiving input report HID: nintendo: improve subcommand reliability HID: nintendo: add rumble support HID: nintendo: add home led support ...
This commit is contained in:
commit
5af06603c4
@ -16,6 +16,20 @@ but then try the legacy ones, too.
|
||||
|
||||
Notice there's a list of functions in include/dt-bindings/leds/common.h .
|
||||
|
||||
* Gamepads and joysticks
|
||||
|
||||
Game controllers may feature LEDs to indicate a player number. This is commonly
|
||||
used on game consoles in which multiple controllers can be connected to a system.
|
||||
The "player LEDs" are then programmed with a pattern to indicate a particular
|
||||
player. For example, a game controller with 4 LEDs, may be programmed with "x---"
|
||||
to indicate player 1, "-x--" to indicate player 2 etcetera where "x" means on.
|
||||
Input drivers can utilize the LED class to expose the individual player LEDs
|
||||
of a game controller using the function "player".
|
||||
Note: tracking and management of Player IDs is the responsibility of user space,
|
||||
though drivers may pick a default value.
|
||||
|
||||
Good: "input*:*:player-{1,2,3,4,5}
|
||||
|
||||
* Keyboards
|
||||
|
||||
Good: "input*:*:capslock"
|
||||
|
@ -13434,6 +13434,12 @@ W: http://www.netlab.is.tsukuba.ac.jp/~yokota/izumi/ninja/
|
||||
F: Documentation/scsi/NinjaSCSI.rst
|
||||
F: drivers/scsi/nsp32*
|
||||
|
||||
NINTENDO HID DRIVER
|
||||
M: Daniel J. Ogorchock <djogorchock@gmail.com>
|
||||
L: linux-input@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/hid/hid-nintendo*
|
||||
|
||||
NIOS2 ARCHITECTURE
|
||||
M: Dinh Nguyen <dinguyen@kernel.org>
|
||||
S: Maintained
|
||||
|
@ -468,6 +468,13 @@ config HID_VIEWSONIC
|
||||
help
|
||||
Support for ViewSonic/Signotec PD1011 signature pad.
|
||||
|
||||
config HID_XIAOMI
|
||||
tristate "Xiaomi"
|
||||
depends on HID
|
||||
help
|
||||
Adds support for side buttons of Xiaomi Mi Dual Mode Wireless
|
||||
Mouse Silent Edition.
|
||||
|
||||
config HID_GYRATION
|
||||
tristate "Gyration remote control"
|
||||
depends on HID
|
||||
@ -731,6 +738,30 @@ config HID_MULTITOUCH
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called hid-multitouch.
|
||||
|
||||
config HID_NINTENDO
|
||||
tristate "Nintendo Joy-Con and Pro Controller support"
|
||||
depends on HID
|
||||
depends on NEW_LEDS
|
||||
depends on LEDS_CLASS
|
||||
select POWER_SUPPLY
|
||||
help
|
||||
Adds support for the Nintendo Switch Joy-Cons and Pro Controller.
|
||||
All controllers support bluetooth, and the Pro Controller also supports
|
||||
its USB mode.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called hid-nintendo.
|
||||
|
||||
config NINTENDO_FF
|
||||
bool "Nintendo Switch controller force feedback support"
|
||||
depends on HID_NINTENDO
|
||||
select INPUT_FF_MEMLESS
|
||||
help
|
||||
Say Y here if you have a Nintendo Switch controller and want to enable
|
||||
force feedback support for it. This works for both joy-cons and the pro
|
||||
controller. For the pro controller, both rumble motors can be controlled
|
||||
individually.
|
||||
|
||||
config HID_NTI
|
||||
tristate "NTI keyboard adapters"
|
||||
help
|
||||
@ -868,6 +899,7 @@ config HID_PLANTRONICS
|
||||
config HID_PLAYSTATION
|
||||
tristate "PlayStation HID Driver"
|
||||
depends on HID
|
||||
depends on LEDS_CLASS_MULTICOLOR
|
||||
select CRC32
|
||||
select POWER_SUPPLY
|
||||
help
|
||||
|
@ -78,6 +78,7 @@ obj-$(CONFIG_HID_MAYFLASH) += hid-mf.o
|
||||
obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o
|
||||
obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o
|
||||
obj-$(CONFIG_HID_MULTITOUCH) += hid-multitouch.o
|
||||
obj-$(CONFIG_HID_NINTENDO) += hid-nintendo.o
|
||||
obj-$(CONFIG_HID_NTI) += hid-nti.o
|
||||
obj-$(CONFIG_HID_NTRIG) += hid-ntrig.o
|
||||
obj-$(CONFIG_HID_ORTEK) += hid-ortek.o
|
||||
@ -125,6 +126,7 @@ hid-uclogic-objs := hid-uclogic-core.o \
|
||||
obj-$(CONFIG_HID_UCLOGIC) += hid-uclogic.o
|
||||
obj-$(CONFIG_HID_UDRAW_PS3) += hid-udraw-ps3.o
|
||||
obj-$(CONFIG_HID_LED) += hid-led.o
|
||||
obj-$(CONFIG_HID_XIAOMI) += hid-xiaomi.o
|
||||
obj-$(CONFIG_HID_XINMO) += hid-xinmo.o
|
||||
obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o
|
||||
obj-$(CONFIG_HID_ZYDACRON) += hid-zydacron.o
|
||||
|
@ -1,9 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* AMD SFH Client Layer
|
||||
* Copyright 2020 Advanced Micro Devices, Inc.
|
||||
* Copyright 2020-2021 Advanced Micro Devices, Inc.
|
||||
* Authors: Nehal Bakulchandra Shah <Nehal-Bakulchandra.Shah@amd.com>
|
||||
* Sandeep Singh <Sandeep.singh@amd.com>
|
||||
* Basavaraj Natikar <Basavaraj.Natikar@amd.com>
|
||||
*/
|
||||
|
||||
#include <linux/dma-mapping.h>
|
||||
|
@ -2,8 +2,10 @@
|
||||
/*
|
||||
* AMD MP2 Sensors transport driver
|
||||
*
|
||||
* Copyright 2020-2021 Advanced Micro Devices, Inc.
|
||||
* Authors: Nehal Bakulchandra Shah <Nehal-bakulchandra.shah@amd.com>
|
||||
* Sandeep Singh <sandeep.singh@amd.com>
|
||||
* Basavaraj Natikar <Basavaraj.Natikar@amd.com>
|
||||
*/
|
||||
#include <linux/hid.h>
|
||||
#include <linux/wait.h>
|
||||
|
@ -2,8 +2,10 @@
|
||||
/*
|
||||
* AMD MP2 Sensors transport driver
|
||||
*
|
||||
* Copyright 2020-2021 Advanced Micro Devices, Inc.
|
||||
* Authors: Nehal Bakulchandra Shah <Nehal-bakulchandra.shah@amd.com>
|
||||
* Sandeep Singh <sandeep.singh@amd.com>
|
||||
* Basavaraj Natikar <Basavaraj.Natikar@amd.com>
|
||||
*/
|
||||
|
||||
#ifndef AMDSFH_HID_H
|
||||
|
@ -1,10 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* AMD MP2 PCIe communication driver
|
||||
* Copyright 2020 Advanced Micro Devices, Inc.
|
||||
* Copyright 2020-2021 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Authors: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
|
||||
* Sandeep Singh <Sandeep.singh@amd.com>
|
||||
* Basavaraj Natikar <Basavaraj.Natikar@amd.com>
|
||||
*/
|
||||
|
||||
#include <linux/bitops.h>
|
||||
@ -234,7 +235,7 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
|
||||
return -ENOMEM;
|
||||
|
||||
privdata->pdev = pdev;
|
||||
pci_set_drvdata(pdev, privdata);
|
||||
dev_set_drvdata(&pdev->dev, privdata);
|
||||
rc = pcim_enable_device(pdev);
|
||||
if (rc)
|
||||
return rc;
|
||||
@ -245,10 +246,13 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
|
||||
|
||||
privdata->mmio = pcim_iomap_table(pdev)[2];
|
||||
pci_set_master(pdev);
|
||||
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
|
||||
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
|
||||
if (rc) {
|
||||
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
|
||||
return rc;
|
||||
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
|
||||
if (rc) {
|
||||
dev_err(&pdev->dev, "failed to set DMA mask\n");
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
privdata->cl_data = devm_kzalloc(&pdev->dev, sizeof(struct amdtp_cl_data), GFP_KERNEL);
|
||||
@ -266,8 +270,7 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
|
||||
|
||||
static int __maybe_unused amd_mp2_pci_resume(struct device *dev)
|
||||
{
|
||||
struct pci_dev *pdev = to_pci_dev(dev);
|
||||
struct amd_mp2_dev *mp2 = pci_get_drvdata(pdev);
|
||||
struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
|
||||
struct amdtp_cl_data *cl_data = mp2->cl_data;
|
||||
struct amd_mp2_sensor_info info;
|
||||
int i, status;
|
||||
@ -292,8 +295,7 @@ static int __maybe_unused amd_mp2_pci_resume(struct device *dev)
|
||||
|
||||
static int __maybe_unused amd_mp2_pci_suspend(struct device *dev)
|
||||
{
|
||||
struct pci_dev *pdev = to_pci_dev(dev);
|
||||
struct amd_mp2_dev *mp2 = pci_get_drvdata(pdev);
|
||||
struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
|
||||
struct amdtp_cl_data *cl_data = mp2->cl_data;
|
||||
int i, status;
|
||||
|
||||
@ -334,3 +336,4 @@ MODULE_DESCRIPTION(DRIVER_DESC);
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
MODULE_AUTHOR("Shyam Sundar S K <Shyam-sundar.S-k@amd.com>");
|
||||
MODULE_AUTHOR("Sandeep Singh <Sandeep.singh@amd.com>");
|
||||
MODULE_AUTHOR("Basavaraj Natikar <Basavaraj.Natikar@amd.com>");
|
||||
|
@ -1,9 +1,10 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* AMD MP2 PCIe communication driver
|
||||
* Copyright 2020 Advanced Micro Devices, Inc.
|
||||
* Copyright 2020-2021 Advanced Micro Devices, Inc.
|
||||
* Authors: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
|
||||
* Sandeep Singh <Sandeep.singh@amd.com>
|
||||
* Basavaraj Natikar <Basavaraj.Natikar@amd.com>
|
||||
*/
|
||||
|
||||
#ifndef PCIE_MP2_AMD_H
|
||||
|
@ -1,9 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* AMD SFH Report Descriptor generator
|
||||
* Copyright 2020 Advanced Micro Devices, Inc.
|
||||
* Copyright 2020-2021 Advanced Micro Devices, Inc.
|
||||
* Authors: Nehal Bakulchandra Shah <Nehal-Bakulchandra.Shah@amd.com>
|
||||
* Sandeep Singh <sandeep.singh@amd.com>
|
||||
* Basavaraj Natikar <Basavaraj.Natikar@amd.com>
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
|
@ -1,9 +1,10 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* HID report descriptors, structures and routines
|
||||
* Copyright 2020 Advanced Micro Devices, Inc.
|
||||
* Copyright 2020-2021 Advanced Micro Devices, Inc.
|
||||
* Authors: Nehal Bakulchandra Shah <Nehal-bakulchandra.shah@amd.com>
|
||||
* Sandeep Singh <Sandeep.singh@amd.com>
|
||||
* Basavaraj Natikar <Basavaraj.Natikar@amd.com>
|
||||
*/
|
||||
|
||||
#ifndef AMD_SFH_HID_DESCRIPTOR_H
|
||||
|
@ -1,9 +1,10 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* HID descriptor stuructures
|
||||
* Copyright 2020 Advanced Micro Devices, Inc.
|
||||
* Copyright 2020-2021 Advanced Micro Devices, Inc.
|
||||
* Authors: Nehal Bakulchandra Shah <Nehal-bakulchandra.shah@amd.com>
|
||||
* Sandeep Singh <Sandeep.singh@amd.com>
|
||||
* Basavaraj Natikar <Basavaraj.Natikar@amd.com>
|
||||
*/
|
||||
|
||||
#ifndef AMD_SFH_HID_REPORT_DESCRIPTOR_H
|
||||
|
@ -24,11 +24,11 @@
|
||||
#define APPLE_RDESC_JIS 0x0001
|
||||
#define APPLE_IGNORE_MOUSE 0x0002
|
||||
#define APPLE_HAS_FN 0x0004
|
||||
#define APPLE_HIDDEV 0x0008
|
||||
/* 0x0010 reserved, was: APPLE_ISO_KEYBOARD */
|
||||
/* 0x0008 reserved, was: APPLE_HIDDEV */
|
||||
#define APPLE_ISO_TILDE_QUIRK 0x0010
|
||||
#define APPLE_MIGHTYMOUSE 0x0020
|
||||
#define APPLE_INVERT_HWHEEL 0x0040
|
||||
#define APPLE_IGNORE_HIDINPUT 0x0080
|
||||
/* 0x0080 reserved, was: APPLE_IGNORE_HIDINPUT */
|
||||
#define APPLE_NUMLOCK_EMULATION 0x0100
|
||||
|
||||
#define APPLE_FLAG_FKEY 0x01
|
||||
@ -40,10 +40,10 @@ module_param(fnmode, uint, 0644);
|
||||
MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "
|
||||
"[1] = fkeyslast, 2 = fkeysfirst)");
|
||||
|
||||
static unsigned int iso_layout = 1;
|
||||
module_param(iso_layout, uint, 0644);
|
||||
MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. "
|
||||
"(0 = disabled, [1] = enabled)");
|
||||
static int iso_layout = -1;
|
||||
module_param(iso_layout, int, 0644);
|
||||
MODULE_PARM_DESC(iso_layout, "Swap the backtick/tilde and greater-than/less-than keys. "
|
||||
"([-1] = auto, 0 = disabled, 1 = enabled)");
|
||||
|
||||
static unsigned int swap_opt_cmd;
|
||||
module_param(swap_opt_cmd, uint, 0644);
|
||||
@ -277,14 +277,13 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
|
||||
}
|
||||
}
|
||||
|
||||
if (iso_layout) {
|
||||
if (hid->country == HID_COUNTRY_INTERNATIONAL_ISO) {
|
||||
trans = apple_find_translation(apple_iso_keyboard, usage->code);
|
||||
if (trans) {
|
||||
input_event_with_scancode(input, usage->type,
|
||||
trans->to, usage->hid, value);
|
||||
return 1;
|
||||
}
|
||||
if (iso_layout > 0 || (iso_layout < 0 && (asc->quirks & APPLE_ISO_TILDE_QUIRK) &&
|
||||
hid->country == HID_COUNTRY_INTERNATIONAL_ISO)) {
|
||||
trans = apple_find_translation(apple_iso_keyboard, usage->code);
|
||||
if (trans) {
|
||||
input_event_with_scancode(input, usage->type,
|
||||
trans->to, usage->hid, value);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -440,7 +439,6 @@ static int apple_probe(struct hid_device *hdev,
|
||||
{
|
||||
unsigned long quirks = id->driver_data;
|
||||
struct apple_sc *asc;
|
||||
unsigned int connect_mask = HID_CONNECT_DEFAULT;
|
||||
int ret;
|
||||
|
||||
asc = devm_kzalloc(&hdev->dev, sizeof(*asc), GFP_KERNEL);
|
||||
@ -459,12 +457,7 @@ static int apple_probe(struct hid_device *hdev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (quirks & APPLE_HIDDEV)
|
||||
connect_mask |= HID_CONNECT_HIDDEV_FORCE;
|
||||
if (quirks & APPLE_IGNORE_HIDINPUT)
|
||||
connect_mask &= ~HID_CONNECT_HIDINPUT;
|
||||
|
||||
ret = hid_hw_start(hdev, connect_mask);
|
||||
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
|
||||
if (ret) {
|
||||
hid_err(hdev, "hw start failed\n");
|
||||
return ret;
|
||||
@ -533,9 +526,11 @@ static const struct hid_device_id apple_devices[] = {
|
||||
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
|
||||
APPLE_ISO_TILDE_QUIRK },
|
||||
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO),
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
|
||||
APPLE_ISO_TILDE_QUIRK },
|
||||
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
|
||||
USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI),
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||
@ -544,14 +539,14 @@ static const struct hid_device_id apple_devices[] = {
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI),
|
||||
.driver_data = APPLE_HAS_FN },
|
||||
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI),
|
||||
.driver_data = APPLE_HAS_FN },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI),
|
||||
.driver_data = APPLE_HAS_FN },
|
||||
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI),
|
||||
.driver_data = APPLE_HAS_FN },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015),
|
||||
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
||||
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015),
|
||||
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015),
|
||||
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
||||
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015),
|
||||
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
|
||||
.driver_data = APPLE_HAS_FN },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
|
||||
@ -633,13 +628,18 @@ static const struct hid_device_id apple_devices[] = {
|
||||
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
|
||||
APPLE_ISO_TILDE_QUIRK },
|
||||
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS),
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
|
||||
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021),
|
||||
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
||||
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021),
|
||||
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
||||
|
||||
{ }
|
||||
};
|
||||
|
@ -854,7 +854,7 @@ static int asus_input_mapping(struct hid_device *hdev,
|
||||
switch (usage->hid & HID_USAGE) {
|
||||
case 0x10: asus_map_key_clear(KEY_BRIGHTNESSDOWN); break;
|
||||
case 0x20: asus_map_key_clear(KEY_BRIGHTNESSUP); break;
|
||||
case 0x35: asus_map_key_clear(KEY_DISPLAY_OFF); break;
|
||||
case 0x35: asus_map_key_clear(KEY_SCREENLOCK); break;
|
||||
case 0x6c: asus_map_key_clear(KEY_SLEEP); break;
|
||||
case 0x7c: asus_map_key_clear(KEY_MICMUTE); break;
|
||||
case 0x82: asus_map_key_clear(KEY_CAMERA); break;
|
||||
|
@ -179,10 +179,9 @@ static int cougar_bind_shared_data(struct hid_device *hdev,
|
||||
|
||||
cougar->shared = shared;
|
||||
|
||||
error = devm_add_action(&hdev->dev, cougar_remove_shared_data, cougar);
|
||||
error = devm_add_action_or_reset(&hdev->dev, cougar_remove_shared_data, cougar);
|
||||
if (error) {
|
||||
mutex_unlock(&cougar_udev_list_lock);
|
||||
cougar_remove_shared_data(cougar);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -160,6 +160,7 @@ static const struct hid_usage_entry hid_usage_table[] = {
|
||||
{0, 0x59, "ButtonType"},
|
||||
{0, 0x5A, "SecondaryBarrelSwitch"},
|
||||
{0, 0x5B, "TransducerSerialNumber"},
|
||||
{0, 0x6e, "TransducerSerialNumber2"},
|
||||
{ 15, 0, "PhysicalInterfaceDevice" },
|
||||
{0, 0x00, "Undefined"},
|
||||
{0, 0x01, "Physical_Interface_Device"},
|
||||
@ -486,8 +487,7 @@ char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
|
||||
|
||||
if (!f) {
|
||||
len = strlen(buf);
|
||||
snprintf(buf+len, max(0, HID_DEBUG_BUFSIZE - len), ".");
|
||||
len++;
|
||||
len += scnprintf(buf + len, HID_DEBUG_BUFSIZE - len, ".");
|
||||
}
|
||||
else {
|
||||
seq_printf(f, ".");
|
||||
@ -498,7 +498,7 @@ char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
|
||||
if (p->usage == (usage & 0xffff)) {
|
||||
if (!f)
|
||||
snprintf(buf + len,
|
||||
max(0,HID_DEBUG_BUFSIZE - len - 1),
|
||||
HID_DEBUG_BUFSIZE - len,
|
||||
"%s", p->description);
|
||||
else
|
||||
seq_printf(f,
|
||||
@ -509,8 +509,8 @@ char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
|
||||
break;
|
||||
}
|
||||
if (!f)
|
||||
snprintf(buf + len, max(0, HID_DEBUG_BUFSIZE - len - 1),
|
||||
"%04x", usage & 0xffff);
|
||||
snprintf(buf + len, HID_DEBUG_BUFSIZE - len, "%04x",
|
||||
usage & 0xffff);
|
||||
else
|
||||
seq_printf(f, "%04x", usage & 0xffff);
|
||||
return buf;
|
||||
|
@ -159,8 +159,8 @@
|
||||
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI 0x0255
|
||||
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256
|
||||
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS 0x0257
|
||||
#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI 0x0267
|
||||
#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI 0x026c
|
||||
#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015 0x0267
|
||||
#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015 0x026c
|
||||
#define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290
|
||||
#define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291
|
||||
#define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292
|
||||
@ -174,6 +174,7 @@
|
||||
#define USB_DEVICE_ID_APPLE_IRCONTROL3 0x8241
|
||||
#define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242
|
||||
#define USB_DEVICE_ID_APPLE_IRCONTROL5 0x8243
|
||||
#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 0x029c
|
||||
|
||||
#define USB_VENDOR_ID_ASUS 0x0486
|
||||
#define USB_DEVICE_ID_ASUS_T91MT 0x0185
|
||||
@ -288,6 +289,9 @@
|
||||
#define USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0020 0x0020
|
||||
#define USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0040 0x0040
|
||||
|
||||
#define USB_VENDOR_ID_CLAY_LOGIC 0x20a0
|
||||
#define USB_DEVICE_ID_NITROKEY_U2F 0x4287
|
||||
|
||||
#define USB_VENDOR_ID_CMEDIA 0x0d8c
|
||||
#define USB_DEVICE_ID_CM109 0x000e
|
||||
#define USB_DEVICE_ID_CMEDIA_HS100B 0x0014
|
||||
@ -917,6 +921,10 @@
|
||||
#define USB_VENDOR_ID_NINTENDO 0x057e
|
||||
#define USB_DEVICE_ID_NINTENDO_WIIMOTE 0x0306
|
||||
#define USB_DEVICE_ID_NINTENDO_WIIMOTE2 0x0330
|
||||
#define USB_DEVICE_ID_NINTENDO_JOYCONL 0x2006
|
||||
#define USB_DEVICE_ID_NINTENDO_JOYCONR 0x2007
|
||||
#define USB_DEVICE_ID_NINTENDO_PROCON 0x2009
|
||||
#define USB_DEVICE_ID_NINTENDO_CHRGGRIP 0x200E
|
||||
|
||||
#define USB_VENDOR_ID_NOVATEK 0x0603
|
||||
#define USB_DEVICE_ID_NOVATEK_PCT 0x0600
|
||||
@ -1276,6 +1284,9 @@
|
||||
#define USB_DEVICE_ID_WEIDA_8752 0xC300
|
||||
#define USB_DEVICE_ID_WEIDA_8755 0xC301
|
||||
|
||||
#define USB_VENDOR_ID_WINBOND 0x0416
|
||||
#define USB_DEVICE_ID_TSTP_MTOUCH 0xc168
|
||||
|
||||
#define USB_VENDOR_ID_WISEGROUP 0x0925
|
||||
#define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005
|
||||
#define USB_DEVICE_ID_SUPER_JOY_BOX_3 0x8888
|
||||
@ -1298,6 +1309,9 @@
|
||||
#define USB_VENDOR_ID_XAT 0x2505
|
||||
#define USB_DEVICE_ID_XAT_CSR 0x0220
|
||||
|
||||
#define USB_VENDOR_ID_XIAOMI 0x2717
|
||||
#define USB_DEVICE_ID_MI_SILENT_MOUSE 0x5014
|
||||
|
||||
#define USB_VENDOR_ID_XIN_MO 0x16c0
|
||||
#define USB_DEVICE_ID_XIN_MO_DUAL_ARCADE 0x05e1
|
||||
#define USB_DEVICE_ID_THT_2P_ARCADE 0x75e1
|
||||
|
@ -871,6 +871,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
|
||||
break;
|
||||
|
||||
case 0x5b: /* TransducerSerialNumber */
|
||||
case 0x6e: /* TransducerSerialNumber2 */
|
||||
usage->type = EV_MSC;
|
||||
usage->code = MSC_SERIAL;
|
||||
bit = input->mscbit;
|
||||
|
@ -193,6 +193,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);
|
||||
/* reserved 0x0014 */
|
||||
#define MT_CLS_WIN_8_FORCE_MULTI_INPUT 0x0015
|
||||
#define MT_CLS_WIN_8_DISABLE_WAKEUP 0x0016
|
||||
#define MT_CLS_WIN_8_NO_STICKY_FINGERS 0x0017
|
||||
|
||||
/* vendor specific classes */
|
||||
#define MT_CLS_3M 0x0101
|
||||
@ -294,6 +295,13 @@ static const struct mt_class mt_classes[] = {
|
||||
MT_QUIRK_WIN8_PTP_BUTTONS |
|
||||
MT_QUIRK_DISABLE_WAKEUP,
|
||||
.export_all_inputs = true },
|
||||
{ .name = MT_CLS_WIN_8_NO_STICKY_FINGERS,
|
||||
.quirks = MT_QUIRK_ALWAYS_VALID |
|
||||
MT_QUIRK_IGNORE_DUPLICATES |
|
||||
MT_QUIRK_HOVERING |
|
||||
MT_QUIRK_CONTACT_CNT_ACCURATE |
|
||||
MT_QUIRK_WIN8_PTP_BUTTONS,
|
||||
.export_all_inputs = true },
|
||||
|
||||
/*
|
||||
* vendor specific classes
|
||||
@ -2120,6 +2128,11 @@ static const struct hid_device_id mt_devices[] = {
|
||||
MT_USB_DEVICE(USB_VENDOR_ID_VTL,
|
||||
USB_DEVICE_ID_VTL_MULTITOUCH_FF3F) },
|
||||
|
||||
/* Winbond Electronics Corp. */
|
||||
{ .driver_data = MT_CLS_WIN_8_NO_STICKY_FINGERS,
|
||||
HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH_WIN_8,
|
||||
USB_VENDOR_ID_WINBOND, USB_DEVICE_ID_TSTP_MTOUCH) },
|
||||
|
||||
/* Wistron panels */
|
||||
{ .driver_data = MT_CLS_NSMU,
|
||||
MT_USB_DEVICE(USB_VENDOR_ID_WISTRON,
|
||||
|
2319
drivers/hid/hid-nintendo.c
Normal file
2319
drivers/hid/hid-nintendo.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,8 @@
|
||||
#include <linux/hid.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/input/mt.h>
|
||||
#include <linux/leds.h>
|
||||
#include <linux/led-class-multicolor.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <asm/unaligned.h>
|
||||
@ -38,6 +40,7 @@ struct ps_device {
|
||||
uint8_t battery_capacity;
|
||||
int battery_status;
|
||||
|
||||
const char *input_dev_name; /* Name of primary input device. */
|
||||
uint8_t mac_address[6]; /* Note: stored in little endian order. */
|
||||
uint32_t hw_version;
|
||||
uint32_t fw_version;
|
||||
@ -53,6 +56,13 @@ struct ps_calibration_data {
|
||||
int sens_denom;
|
||||
};
|
||||
|
||||
struct ps_led_info {
|
||||
const char *name;
|
||||
const char *color;
|
||||
enum led_brightness (*brightness_get)(struct led_classdev *cdev);
|
||||
int (*brightness_set)(struct led_classdev *cdev, enum led_brightness);
|
||||
};
|
||||
|
||||
/* Seed values for DualShock4 / DualSense CRC32 for different report types. */
|
||||
#define PS_INPUT_CRC32_SEED 0xA1
|
||||
#define PS_OUTPUT_CRC32_SEED 0xA2
|
||||
@ -147,6 +157,7 @@ struct dualsense {
|
||||
uint8_t motor_right;
|
||||
|
||||
/* RGB lightbar */
|
||||
struct led_classdev_mc lightbar;
|
||||
bool update_lightbar;
|
||||
uint8_t lightbar_red;
|
||||
uint8_t lightbar_green;
|
||||
@ -288,6 +299,8 @@ static const struct {int x; int y; } ps_gamepad_hat_mapping[] = {
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
static void dualsense_set_lightbar(struct dualsense *ds, uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
/*
|
||||
* Add a new ps_device to ps_devices if it doesn't exist.
|
||||
* Return error on duplicate device, which can happen if the same
|
||||
@ -525,6 +538,71 @@ static int ps_get_report(struct hid_device *hdev, uint8_t report_id, uint8_t *bu
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ps_led_register(struct ps_device *ps_dev, struct led_classdev *led,
|
||||
const struct ps_led_info *led_info)
|
||||
{
|
||||
int ret;
|
||||
|
||||
led->name = devm_kasprintf(&ps_dev->hdev->dev, GFP_KERNEL,
|
||||
"%s:%s:%s", ps_dev->input_dev_name, led_info->color, led_info->name);
|
||||
|
||||
if (!led->name)
|
||||
return -ENOMEM;
|
||||
|
||||
led->brightness = 0;
|
||||
led->max_brightness = 1;
|
||||
led->flags = LED_CORE_SUSPENDRESUME;
|
||||
led->brightness_get = led_info->brightness_get;
|
||||
led->brightness_set_blocking = led_info->brightness_set;
|
||||
|
||||
ret = devm_led_classdev_register(&ps_dev->hdev->dev, led);
|
||||
if (ret) {
|
||||
hid_err(ps_dev->hdev, "Failed to register LED %s: %d\n", led_info->name, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Register a DualSense/DualShock4 RGB lightbar represented by a multicolor LED. */
|
||||
static int ps_lightbar_register(struct ps_device *ps_dev, struct led_classdev_mc *lightbar_mc_dev,
|
||||
int (*brightness_set)(struct led_classdev *, enum led_brightness))
|
||||
{
|
||||
struct hid_device *hdev = ps_dev->hdev;
|
||||
struct mc_subled *mc_led_info;
|
||||
struct led_classdev *led_cdev;
|
||||
int ret;
|
||||
|
||||
mc_led_info = devm_kmalloc_array(&hdev->dev, 3, sizeof(*mc_led_info),
|
||||
GFP_KERNEL | __GFP_ZERO);
|
||||
if (!mc_led_info)
|
||||
return -ENOMEM;
|
||||
|
||||
mc_led_info[0].color_index = LED_COLOR_ID_RED;
|
||||
mc_led_info[1].color_index = LED_COLOR_ID_GREEN;
|
||||
mc_led_info[2].color_index = LED_COLOR_ID_BLUE;
|
||||
|
||||
lightbar_mc_dev->subled_info = mc_led_info;
|
||||
lightbar_mc_dev->num_colors = 3;
|
||||
|
||||
led_cdev = &lightbar_mc_dev->led_cdev;
|
||||
led_cdev->name = devm_kasprintf(&hdev->dev, GFP_KERNEL, "%s:rgb:indicator",
|
||||
ps_dev->input_dev_name);
|
||||
if (!led_cdev->name)
|
||||
return -ENOMEM;
|
||||
led_cdev->brightness = 255;
|
||||
led_cdev->max_brightness = 255;
|
||||
led_cdev->brightness_set_blocking = brightness_set;
|
||||
|
||||
ret = devm_led_classdev_multicolor_register(&hdev->dev, lightbar_mc_dev);
|
||||
if (ret < 0) {
|
||||
hid_err(hdev, "Cannot register multicolor LED device\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct input_dev *ps_sensors_create(struct hid_device *hdev, int accel_range, int accel_res,
|
||||
int gyro_range, int gyro_res)
|
||||
{
|
||||
@ -761,6 +839,53 @@ err_free:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dualsense_lightbar_set_brightness(struct led_classdev *cdev,
|
||||
enum led_brightness brightness)
|
||||
{
|
||||
struct led_classdev_mc *mc_cdev = lcdev_to_mccdev(cdev);
|
||||
struct dualsense *ds = container_of(mc_cdev, struct dualsense, lightbar);
|
||||
uint8_t red, green, blue;
|
||||
|
||||
led_mc_calc_color_components(mc_cdev, brightness);
|
||||
red = mc_cdev->subled_info[0].brightness;
|
||||
green = mc_cdev->subled_info[1].brightness;
|
||||
blue = mc_cdev->subled_info[2].brightness;
|
||||
|
||||
dualsense_set_lightbar(ds, red, green, blue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static enum led_brightness dualsense_player_led_get_brightness(struct led_classdev *led)
|
||||
{
|
||||
struct hid_device *hdev = to_hid_device(led->dev->parent);
|
||||
struct dualsense *ds = hid_get_drvdata(hdev);
|
||||
|
||||
return !!(ds->player_leds_state & BIT(led - ds->player_leds));
|
||||
}
|
||||
|
||||
static int dualsense_player_led_set_brightness(struct led_classdev *led, enum led_brightness value)
|
||||
{
|
||||
struct hid_device *hdev = to_hid_device(led->dev->parent);
|
||||
struct dualsense *ds = hid_get_drvdata(hdev);
|
||||
unsigned long flags;
|
||||
unsigned int led_index;
|
||||
|
||||
spin_lock_irqsave(&ds->base.lock, flags);
|
||||
|
||||
led_index = led - ds->player_leds;
|
||||
if (value == LED_OFF)
|
||||
ds->player_leds_state &= ~BIT(led_index);
|
||||
else
|
||||
ds->player_leds_state |= BIT(led_index);
|
||||
|
||||
ds->update_player_leds = true;
|
||||
spin_unlock_irqrestore(&ds->base.lock, flags);
|
||||
|
||||
schedule_work(&ds->output_worker);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dualsense_init_output_report(struct dualsense *ds, struct dualsense_output_report *rp,
|
||||
void *buf)
|
||||
{
|
||||
@ -1106,10 +1231,14 @@ static int dualsense_reset_leds(struct dualsense *ds)
|
||||
|
||||
static void dualsense_set_lightbar(struct dualsense *ds, uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&ds->base.lock, flags);
|
||||
ds->update_lightbar = true;
|
||||
ds->lightbar_red = red;
|
||||
ds->lightbar_green = green;
|
||||
ds->lightbar_blue = blue;
|
||||
spin_unlock_irqrestore(&ds->base.lock, flags);
|
||||
|
||||
schedule_work(&ds->output_worker);
|
||||
}
|
||||
@ -1142,7 +1271,20 @@ static struct ps_device *dualsense_create(struct hid_device *hdev)
|
||||
struct dualsense *ds;
|
||||
struct ps_device *ps_dev;
|
||||
uint8_t max_output_report_size;
|
||||
int ret;
|
||||
int i, ret;
|
||||
|
||||
static const struct ps_led_info player_leds_info[] = {
|
||||
{ LED_FUNCTION_PLAYER1, "white", dualsense_player_led_get_brightness,
|
||||
dualsense_player_led_set_brightness },
|
||||
{ LED_FUNCTION_PLAYER2, "white", dualsense_player_led_get_brightness,
|
||||
dualsense_player_led_set_brightness },
|
||||
{ LED_FUNCTION_PLAYER3, "white", dualsense_player_led_get_brightness,
|
||||
dualsense_player_led_set_brightness },
|
||||
{ LED_FUNCTION_PLAYER4, "white", dualsense_player_led_get_brightness,
|
||||
dualsense_player_led_set_brightness },
|
||||
{ LED_FUNCTION_PLAYER5, "white", dualsense_player_led_get_brightness,
|
||||
dualsense_player_led_set_brightness }
|
||||
};
|
||||
|
||||
ds = devm_kzalloc(&hdev->dev, sizeof(*ds), GFP_KERNEL);
|
||||
if (!ds)
|
||||
@ -1196,6 +1338,8 @@ static struct ps_device *dualsense_create(struct hid_device *hdev)
|
||||
ret = PTR_ERR(ds->gamepad);
|
||||
goto err;
|
||||
}
|
||||
/* Use gamepad input device name as primary device name for e.g. LEDs */
|
||||
ps_dev->input_dev_name = dev_name(&ds->gamepad->dev);
|
||||
|
||||
ds->sensors = ps_sensors_create(hdev, DS_ACC_RANGE, DS_ACC_RES_PER_G,
|
||||
DS_GYRO_RANGE, DS_GYRO_RES_PER_DEG_S);
|
||||
@ -1223,8 +1367,21 @@ static struct ps_device *dualsense_create(struct hid_device *hdev)
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = ps_lightbar_register(ps_dev, &ds->lightbar, dualsense_lightbar_set_brightness);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
/* Set default lightbar color. */
|
||||
dualsense_set_lightbar(ds, 0, 0, 128); /* blue */
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(player_leds_info); i++) {
|
||||
const struct ps_led_info *led_info = &player_leds_info[i];
|
||||
|
||||
ret = ps_led_register(ps_dev, &ds->player_leds[i], led_info);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = ps_device_set_player_id(ps_dev);
|
||||
if (ret) {
|
||||
hid_err(hdev, "Failed to assign player id for DualSense: %d\n", ret);
|
||||
|
@ -299,9 +299,10 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
||||
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI) },
|
||||
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) },
|
||||
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021) },
|
||||
#endif
|
||||
#if IS_ENABLED(CONFIG_HID_APPLEIR)
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL) },
|
||||
|
@ -26,6 +26,30 @@
|
||||
|
||||
#define HID_REPORT_SIZE 64
|
||||
|
||||
enum hw_revision {
|
||||
HW_U2FZERO,
|
||||
HW_NITROKEY_U2F,
|
||||
};
|
||||
|
||||
struct hw_revision_config {
|
||||
u8 rng_cmd;
|
||||
u8 wink_cmd;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
static const struct hw_revision_config hw_configs[] = {
|
||||
[HW_U2FZERO] = {
|
||||
.rng_cmd = 0x21,
|
||||
.wink_cmd = 0x24,
|
||||
.name = "U2F Zero",
|
||||
},
|
||||
[HW_NITROKEY_U2F] = {
|
||||
.rng_cmd = 0xc0,
|
||||
.wink_cmd = 0xc2,
|
||||
.name = "NitroKey U2F",
|
||||
},
|
||||
};
|
||||
|
||||
/* We only use broadcast (CID-less) messages */
|
||||
#define CID_BROADCAST 0xffffffff
|
||||
|
||||
@ -52,10 +76,6 @@ struct u2f_hid_report {
|
||||
|
||||
#define U2F_HID_MSG_LEN(f) (size_t)(((f).init.bcnth << 8) + (f).init.bcntl)
|
||||
|
||||
/* Custom extensions to the U2FHID protocol */
|
||||
#define U2F_CUSTOM_GET_RNG 0x21
|
||||
#define U2F_CUSTOM_WINK 0x24
|
||||
|
||||
struct u2fzero_device {
|
||||
struct hid_device *hdev;
|
||||
struct urb *urb; /* URB for the RNG data */
|
||||
@ -67,6 +87,7 @@ struct u2fzero_device {
|
||||
u8 *buf_in;
|
||||
struct mutex lock;
|
||||
bool present;
|
||||
kernel_ulong_t hw_revision;
|
||||
};
|
||||
|
||||
static int u2fzero_send(struct u2fzero_device *dev, struct u2f_hid_report *req)
|
||||
@ -132,7 +153,7 @@ static int u2fzero_recv(struct u2fzero_device *dev,
|
||||
|
||||
ret = (wait_for_completion_timeout(
|
||||
&ctx.done, msecs_to_jiffies(USB_CTRL_SET_TIMEOUT)));
|
||||
if (ret < 0) {
|
||||
if (ret == 0) {
|
||||
usb_kill_urb(dev->urb);
|
||||
hid_err(hdev, "urb submission timed out");
|
||||
} else {
|
||||
@ -154,7 +175,7 @@ static int u2fzero_blink(struct led_classdev *ldev)
|
||||
.report_type = 0,
|
||||
.msg.cid = CID_BROADCAST,
|
||||
.msg.init = {
|
||||
.cmd = U2F_CUSTOM_WINK,
|
||||
.cmd = hw_configs[dev->hw_revision].wink_cmd,
|
||||
.bcnth = 0,
|
||||
.bcntl = 0,
|
||||
.data = {0},
|
||||
@ -182,7 +203,7 @@ static int u2fzero_rng_read(struct hwrng *rng, void *data,
|
||||
.report_type = 0,
|
||||
.msg.cid = CID_BROADCAST,
|
||||
.msg.init = {
|
||||
.cmd = U2F_CUSTOM_GET_RNG,
|
||||
.cmd = hw_configs[dev->hw_revision].rng_cmd,
|
||||
.bcnth = 0,
|
||||
.bcntl = 0,
|
||||
.data = {0},
|
||||
@ -191,6 +212,8 @@ static int u2fzero_rng_read(struct hwrng *rng, void *data,
|
||||
struct u2f_hid_msg resp;
|
||||
int ret;
|
||||
size_t actual_length;
|
||||
/* valid packets must have a correct header */
|
||||
int min_length = offsetof(struct u2f_hid_msg, init.data);
|
||||
|
||||
if (!dev->present) {
|
||||
hid_dbg(dev->hdev, "device not present");
|
||||
@ -200,12 +223,12 @@ static int u2fzero_rng_read(struct hwrng *rng, void *data,
|
||||
ret = u2fzero_recv(dev, &req, &resp);
|
||||
|
||||
/* ignore errors or packets without data */
|
||||
if (ret < offsetof(struct u2f_hid_msg, init.data))
|
||||
if (ret < min_length)
|
||||
return 0;
|
||||
|
||||
/* only take the minimum amount of data it is safe to take */
|
||||
actual_length = min3((size_t)ret - offsetof(struct u2f_hid_msg,
|
||||
init.data), U2F_HID_MSG_LEN(resp), max);
|
||||
actual_length = min3((size_t)ret - min_length,
|
||||
U2F_HID_MSG_LEN(resp), max);
|
||||
|
||||
memcpy(data, resp.init.data, actual_length);
|
||||
|
||||
@ -295,6 +318,8 @@ static int u2fzero_probe(struct hid_device *hdev,
|
||||
if (dev == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
dev->hw_revision = id->driver_data;
|
||||
|
||||
dev->buf_out = devm_kmalloc(&hdev->dev,
|
||||
sizeof(struct u2f_hid_report), GFP_KERNEL);
|
||||
if (dev->buf_out == NULL)
|
||||
@ -329,7 +354,7 @@ static int u2fzero_probe(struct hid_device *hdev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
hid_info(hdev, "U2F Zero LED initialised\n");
|
||||
hid_info(hdev, "%s LED initialised\n", hw_configs[dev->hw_revision].name);
|
||||
|
||||
ret = u2fzero_init_hwrng(dev, minor);
|
||||
if (ret) {
|
||||
@ -337,7 +362,7 @@ static int u2fzero_probe(struct hid_device *hdev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
hid_info(hdev, "U2F Zero RNG initialised\n");
|
||||
hid_info(hdev, "%s RNG initialised\n", hw_configs[dev->hw_revision].name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -357,7 +382,11 @@ static void u2fzero_remove(struct hid_device *hdev)
|
||||
|
||||
static const struct hid_device_id u2fzero_table[] = {
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL,
|
||||
USB_DEVICE_ID_U2F_ZERO) },
|
||||
USB_DEVICE_ID_U2F_ZERO),
|
||||
.driver_data = HW_U2FZERO },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_CLAY_LOGIC,
|
||||
USB_DEVICE_ID_NITROKEY_U2F),
|
||||
.driver_data = HW_NITROKEY_U2F },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(hid, u2fzero_table);
|
||||
|
94
drivers/hid/hid-xiaomi.c
Normal file
94
drivers/hid/hid-xiaomi.c
Normal file
@ -0,0 +1,94 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* HID driver for Xiaomi Mi Dual Mode Wireless Mouse Silent Edition
|
||||
*
|
||||
* Copyright (c) 2021 Ilya Skriblovsky
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/hid.h>
|
||||
|
||||
#include "hid-ids.h"
|
||||
|
||||
/* Fixed Mi Silent Mouse report descriptor */
|
||||
/* Button's Usage Maximum changed from 3 to 5 to make side buttons work */
|
||||
#define MI_SILENT_MOUSE_ORIG_RDESC_LENGTH 87
|
||||
static __u8 mi_silent_mouse_rdesc_fixed[] = {
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x09, 0x02, /* Usage (Mouse), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
0x85, 0x03, /* Report ID (3), */
|
||||
0x09, 0x01, /* Usage (Pointer), */
|
||||
0xA1, 0x00, /* Collection (Physical), */
|
||||
0x05, 0x09, /* Usage Page (Button), */
|
||||
0x19, 0x01, /* Usage Minimum (01h), */
|
||||
0x29, 0x05, /* X */ /* Usage Maximum (05h), */
|
||||
0x15, 0x00, /* Logical Minimum (0), */
|
||||
0x25, 0x01, /* Logical Maximum (1), */
|
||||
0x75, 0x01, /* Report Size (1), */
|
||||
0x95, 0x05, /* Report Count (5), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x75, 0x03, /* Report Size (3), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0x81, 0x01, /* Input (Constant), */
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x09, 0x30, /* Usage (X), */
|
||||
0x09, 0x31, /* Usage (Y), */
|
||||
0x15, 0x81, /* Logical Minimum (-127), */
|
||||
0x25, 0x7F, /* Logical Maximum (127), */
|
||||
0x75, 0x08, /* Report Size (8), */
|
||||
0x95, 0x02, /* Report Count (2), */
|
||||
0x81, 0x06, /* Input (Variable, Relative), */
|
||||
0x09, 0x38, /* Usage (Wheel), */
|
||||
0x15, 0x81, /* Logical Minimum (-127), */
|
||||
0x25, 0x7F, /* Logical Maximum (127), */
|
||||
0x75, 0x08, /* Report Size (8), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0x81, 0x06, /* Input (Variable, Relative), */
|
||||
0xC0, /* End Collection, */
|
||||
0xC0, /* End Collection, */
|
||||
0x06, 0x01, 0xFF, /* Usage Page (FF01h), */
|
||||
0x09, 0x01, /* Usage (01h), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
0x85, 0x05, /* Report ID (5), */
|
||||
0x09, 0x05, /* Usage (05h), */
|
||||
0x15, 0x00, /* Logical Minimum (0), */
|
||||
0x26, 0xFF, 0x00, /* Logical Maximum (255), */
|
||||
0x75, 0x08, /* Report Size (8), */
|
||||
0x95, 0x04, /* Report Count (4), */
|
||||
0xB1, 0x02, /* Feature (Variable), */
|
||||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
static __u8 *xiaomi_report_fixup(struct hid_device *hdev, __u8 *rdesc,
|
||||
unsigned int *rsize)
|
||||
{
|
||||
switch (hdev->product) {
|
||||
case USB_DEVICE_ID_MI_SILENT_MOUSE:
|
||||
if (*rsize == MI_SILENT_MOUSE_ORIG_RDESC_LENGTH) {
|
||||
hid_info(hdev, "fixing up Mi Silent Mouse report descriptor\n");
|
||||
rdesc = mi_silent_mouse_rdesc_fixed;
|
||||
*rsize = sizeof(mi_silent_mouse_rdesc_fixed);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return rdesc;
|
||||
}
|
||||
|
||||
static const struct hid_device_id xiaomi_devices[] = {
|
||||
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_XIAOMI, USB_DEVICE_ID_MI_SILENT_MOUSE) },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(hid, xiaomi_devices);
|
||||
|
||||
static struct hid_driver xiaomi_driver = {
|
||||
.name = "xiaomi",
|
||||
.id_table = xiaomi_devices,
|
||||
.report_fixup = xiaomi_report_fixup,
|
||||
};
|
||||
module_hid_driver(xiaomi_driver);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Ilya Skriblovsky <IlyaSkriblovsky@gmail.com>");
|
||||
MODULE_DESCRIPTION("Fixing side buttons of Xiaomi Mi Silent Mouse");
|
@ -881,8 +881,8 @@ static int wacom_add_shared_data(struct hid_device *hdev)
|
||||
if (!data) {
|
||||
data = kzalloc(sizeof(struct wacom_hdev_data), GFP_KERNEL);
|
||||
if (!data) {
|
||||
retval = -ENOMEM;
|
||||
goto out;
|
||||
mutex_unlock(&wacom_udev_list_lock);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
kref_init(&data->kref);
|
||||
@ -890,22 +890,19 @@ static int wacom_add_shared_data(struct hid_device *hdev)
|
||||
list_add_tail(&data->list, &wacom_udev_list);
|
||||
}
|
||||
|
||||
mutex_unlock(&wacom_udev_list_lock);
|
||||
|
||||
wacom_wac->shared = &data->shared;
|
||||
|
||||
retval = devm_add_action(&hdev->dev, wacom_remove_shared_data, wacom);
|
||||
if (retval) {
|
||||
mutex_unlock(&wacom_udev_list_lock);
|
||||
wacom_remove_shared_data(wacom);
|
||||
retval = devm_add_action_or_reset(&hdev->dev, wacom_remove_shared_data, wacom);
|
||||
if (retval)
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH)
|
||||
wacom_wac->shared->touch = hdev;
|
||||
else if (wacom_wac->features.device_type & WACOM_DEVICETYPE_PEN)
|
||||
wacom_wac->shared->pen = hdev;
|
||||
|
||||
out:
|
||||
mutex_unlock(&wacom_udev_list_lock);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -758,6 +758,12 @@ static void joydev_cleanup(struct joydev *joydev)
|
||||
#define USB_VENDOR_ID_THQ 0x20d6
|
||||
#define USB_DEVICE_ID_THQ_PS3_UDRAW 0xcb17
|
||||
|
||||
#define USB_VENDOR_ID_NINTENDO 0x057e
|
||||
#define USB_DEVICE_ID_NINTENDO_JOYCONL 0x2006
|
||||
#define USB_DEVICE_ID_NINTENDO_JOYCONR 0x2007
|
||||
#define USB_DEVICE_ID_NINTENDO_PROCON 0x2009
|
||||
#define USB_DEVICE_ID_NINTENDO_CHRGGRIP 0x200E
|
||||
|
||||
#define ACCEL_DEV(vnd, prd) \
|
||||
{ \
|
||||
.flags = INPUT_DEVICE_ID_MATCH_VENDOR | \
|
||||
@ -789,6 +795,10 @@ static const struct input_device_id joydev_blacklist[] = {
|
||||
ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2),
|
||||
ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE),
|
||||
ACCEL_DEV(USB_VENDOR_ID_THQ, USB_DEVICE_ID_THQ_PS3_UDRAW),
|
||||
ACCEL_DEV(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_PROCON),
|
||||
ACCEL_DEV(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_CHRGGRIP),
|
||||
ACCEL_DEV(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_JOYCONL),
|
||||
ACCEL_DEV(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_JOYCONR),
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
|
@ -60,6 +60,13 @@
|
||||
#define LED_FUNCTION_MICMUTE "micmute"
|
||||
#define LED_FUNCTION_MUTE "mute"
|
||||
|
||||
/* Used for player LEDs as found on game controllers from e.g. Nintendo, Sony. */
|
||||
#define LED_FUNCTION_PLAYER1 "player-1"
|
||||
#define LED_FUNCTION_PLAYER2 "player-2"
|
||||
#define LED_FUNCTION_PLAYER3 "player-3"
|
||||
#define LED_FUNCTION_PLAYER4 "player-4"
|
||||
#define LED_FUNCTION_PLAYER5 "player-5"
|
||||
|
||||
/* Miscelleaus functions. Use functions above if you can. */
|
||||
#define LED_FUNCTION_ACTIVITY "activity"
|
||||
#define LED_FUNCTION_ALARM "alarm"
|
||||
|
Loading…
Reference in New Issue
Block a user