mirror of
https://github.com/torvalds/linux.git
synced 2024-12-01 08:31:37 +00:00
9d262f35b1
make allmodconfig && make W=1 C=1 reports: WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-a4tech.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-apple.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-aureal.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-belkin.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-betopff.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-bigbenff.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-cherry.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-chicony.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-cypress.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-dr.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-emsff.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-elecom.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-elo.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-evision.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-ezkey.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-vivaldi-common.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-google-hammer.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-google-stadiaff.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-gyration.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-holtek-kbd.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-holtek-mouse.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-ite.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-kensington.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-keytouch.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-kye.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-lcpower.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-lenovo.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-logitech.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-magicmouse.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-maltron.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-mf.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-megaworld.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-microsoft.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-monterey.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-ntrig.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-ortek.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-prodikeys.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-pl.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-petalynx.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-primax.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-razer.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-redragon.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-retrode.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-saitek.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-samsung.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-semitek.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-sjoy.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-sony.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-speedlink.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-steam.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-steelseries.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-sunplus.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-gaff.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-tmff.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-tivo.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-topseed.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-twinhan.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-uclogic.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-xinmo.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-zpff.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-zydacron.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-viewsonic.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-waltop.o WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-winwing.o Add the missing invocations of the MODULE_DESCRIPTION() macro. Note: All HID drivers that had explicit entries in the MAINTAINERS file were fixed individually. This patch fixes all remaining HID drivers that fall under the generic "HID CORE LAYER" entry in the MAINTAINERS file. Almost all descriptions were taken from the header comment in each file. Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com> Link: https://lore.kernel.org/r/20240604-md-hid-misc-v1-1-4f9560796f3c@quicinc.com Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
209 lines
5.3 KiB
C
209 lines
5.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* HID driver for Saitek devices.
|
|
*
|
|
* PS1000 (USB gamepad):
|
|
* Fixes the HID report descriptor by removing a non-existent axis and
|
|
* clearing the constant bit on the input reports for buttons and d-pad.
|
|
* (This module is based on "hid-ortek".)
|
|
* Copyright (c) 2012 Andreas Hübner
|
|
*
|
|
* R.A.T.7, R.A.T.9, M.M.O.7 (USB gaming mice):
|
|
* Fixes the mode button which cycles through three constantly pressed
|
|
* buttons. All three press events are mapped to one button and the
|
|
* missing release event is generated immediately.
|
|
*/
|
|
|
|
/*
|
|
*/
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/hid.h>
|
|
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
|
|
#include "hid-ids.h"
|
|
|
|
#define SAITEK_FIX_PS1000 0x0001
|
|
#define SAITEK_RELEASE_MODE_RAT7 0x0002
|
|
#define SAITEK_RELEASE_MODE_MMO7 0x0004
|
|
|
|
struct saitek_sc {
|
|
unsigned long quirks;
|
|
int mode;
|
|
};
|
|
|
|
static int saitek_probe(struct hid_device *hdev,
|
|
const struct hid_device_id *id)
|
|
{
|
|
unsigned long quirks = id->driver_data;
|
|
struct saitek_sc *ssc;
|
|
int ret;
|
|
|
|
ssc = devm_kzalloc(&hdev->dev, sizeof(*ssc), GFP_KERNEL);
|
|
if (ssc == NULL) {
|
|
hid_err(hdev, "can't alloc saitek descriptor\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
ssc->quirks = quirks;
|
|
ssc->mode = -1;
|
|
|
|
hid_set_drvdata(hdev, ssc);
|
|
|
|
ret = hid_parse(hdev);
|
|
if (ret) {
|
|
hid_err(hdev, "parse failed\n");
|
|
return ret;
|
|
}
|
|
|
|
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
|
|
if (ret) {
|
|
hid_err(hdev, "hw start failed\n");
|
|
return ret;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static __u8 *saitek_report_fixup(struct hid_device *hdev, __u8 *rdesc,
|
|
unsigned int *rsize)
|
|
{
|
|
struct saitek_sc *ssc = hid_get_drvdata(hdev);
|
|
|
|
if ((ssc->quirks & SAITEK_FIX_PS1000) && *rsize == 137 &&
|
|
rdesc[20] == 0x09 && rdesc[21] == 0x33 &&
|
|
rdesc[94] == 0x81 && rdesc[95] == 0x03 &&
|
|
rdesc[110] == 0x81 && rdesc[111] == 0x03) {
|
|
|
|
hid_info(hdev, "Fixing up Saitek PS1000 report descriptor\n");
|
|
|
|
/* convert spurious axis to a "noop" Logical Minimum (0) */
|
|
rdesc[20] = 0x15;
|
|
rdesc[21] = 0x00;
|
|
|
|
/* clear constant bit on buttons and d-pad */
|
|
rdesc[95] = 0x02;
|
|
rdesc[111] = 0x02;
|
|
|
|
}
|
|
return rdesc;
|
|
}
|
|
|
|
static int saitek_raw_event(struct hid_device *hdev,
|
|
struct hid_report *report, u8 *raw_data, int size)
|
|
{
|
|
struct saitek_sc *ssc = hid_get_drvdata(hdev);
|
|
|
|
if (ssc->quirks & SAITEK_RELEASE_MODE_RAT7 && size == 7) {
|
|
/* R.A.T.7 uses bits 13, 14, 15 for the mode */
|
|
int mode = -1;
|
|
if (raw_data[1] & 0x01)
|
|
mode = 0;
|
|
else if (raw_data[1] & 0x02)
|
|
mode = 1;
|
|
else if (raw_data[1] & 0x04)
|
|
mode = 2;
|
|
|
|
/* clear mode bits */
|
|
raw_data[1] &= ~0x07;
|
|
|
|
if (mode != ssc->mode) {
|
|
hid_dbg(hdev, "entered mode %d\n", mode);
|
|
if (ssc->mode != -1) {
|
|
/* use bit 13 as the mode button */
|
|
raw_data[1] |= 0x04;
|
|
}
|
|
ssc->mode = mode;
|
|
}
|
|
} else if (ssc->quirks & SAITEK_RELEASE_MODE_MMO7 && size == 8) {
|
|
|
|
/* M.M.O.7 uses bits 8, 22, 23 for the mode */
|
|
int mode = -1;
|
|
if (raw_data[1] & 0x80)
|
|
mode = 0;
|
|
else if (raw_data[2] & 0x01)
|
|
mode = 1;
|
|
else if (raw_data[2] & 0x02)
|
|
mode = 2;
|
|
|
|
/* clear mode bits */
|
|
raw_data[1] &= ~0x80;
|
|
raw_data[2] &= ~0x03;
|
|
|
|
if (mode != ssc->mode) {
|
|
hid_dbg(hdev, "entered mode %d\n", mode);
|
|
if (ssc->mode != -1) {
|
|
/* use bit 8 as the mode button, bits 22
|
|
* and 23 do not represent buttons
|
|
* according to the HID report descriptor
|
|
*/
|
|
raw_data[1] |= 0x80;
|
|
}
|
|
ssc->mode = mode;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int saitek_event(struct hid_device *hdev, struct hid_field *field,
|
|
struct hid_usage *usage, __s32 value)
|
|
{
|
|
struct saitek_sc *ssc = hid_get_drvdata(hdev);
|
|
struct input_dev *input = field->hidinput->input;
|
|
|
|
if (usage->type == EV_KEY && value &&
|
|
(((ssc->quirks & SAITEK_RELEASE_MODE_RAT7) &&
|
|
usage->code - BTN_MOUSE == 10) ||
|
|
((ssc->quirks & SAITEK_RELEASE_MODE_MMO7) &&
|
|
usage->code - BTN_MOUSE == 15))) {
|
|
|
|
input_report_key(input, usage->code, 1);
|
|
|
|
/* report missing release event */
|
|
input_report_key(input, usage->code, 0);
|
|
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct hid_device_id saitek_devices[] = {
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000),
|
|
.driver_data = SAITEK_FIX_PS1000 },
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT5),
|
|
.driver_data = SAITEK_RELEASE_MODE_RAT7 },
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7_OLD),
|
|
.driver_data = SAITEK_RELEASE_MODE_RAT7 },
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7),
|
|
.driver_data = SAITEK_RELEASE_MODE_RAT7 },
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7_CONTAGION),
|
|
.driver_data = SAITEK_RELEASE_MODE_RAT7 },
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT9),
|
|
.driver_data = SAITEK_RELEASE_MODE_RAT7 },
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9),
|
|
.driver_data = SAITEK_RELEASE_MODE_RAT7 },
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_MMO7),
|
|
.driver_data = SAITEK_RELEASE_MODE_MMO7 },
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_MMO7),
|
|
.driver_data = SAITEK_RELEASE_MODE_MMO7 },
|
|
{ }
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(hid, saitek_devices);
|
|
|
|
static struct hid_driver saitek_driver = {
|
|
.name = "saitek",
|
|
.id_table = saitek_devices,
|
|
.probe = saitek_probe,
|
|
.report_fixup = saitek_report_fixup,
|
|
.raw_event = saitek_raw_event,
|
|
.event = saitek_event,
|
|
};
|
|
module_hid_driver(saitek_driver);
|
|
|
|
MODULE_DESCRIPTION("HID driver for Saitek devices.");
|
|
MODULE_LICENSE("GPL");
|