Skip to content

Commit aa051d3

Browse files
committed
Merge tag 'for-linus-2022052401' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID updates from Jiri Kosina: - support for pens with 3 buttons with Wacom driver (Joshua Dickens) - support for HID_DG_SCANTIME to report the timestamp for pen and touch events in Wacom driver (Joshua Dickens) - support for sensor discovery in amd-sfh driver (Basavaraj Natikar) - support for wider variety of Huion tablets ported from DIGImend project (José Expósito, Nikolai Kondrashov) - new device IDs and other assorted small code cleanups * tag 'for-linus-2022052401' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (44 commits) HID: apple: Properly handle function keys on Keychron keyboards HID: uclogic: Switch to Digitizer usage for styluses HID: uclogic: Add pen support for XP-PEN Star 06 HID: uclogic: Differentiate touch ring and touch strip HID: uclogic: Always shift touch reports to zero HID: uclogic: Do not focus on touch ring only HID: uclogic: Return raw parameters from v2 pen init HID: uclogic: Move param printing to a function HID: core: Display "SENSOR HUB" for sensor hub bus string in hid_info HID: amd_sfh: Move bus declaration outside of amd-sfh HID: amd_sfh: Add physical location to HID device HID: amd_sfh: Modify the hid name HID: amd_sfh: Modify the bus name HID: amd_sfh: Add sensor name by index for debug info HID: amd_sfh: Add support for sensor discovery HID: bigben: fix slab-out-of-bounds Write in bigben_probe Hid: wacom: Fix kernel test robot warning HID: uclogic: Disable pen usage for Huion keyboard interfaces HID: uclogic: Support disabling pen usage HID: uclogic: Pass keyboard reports as is ...
2 parents d8e0f97 + 07d1721 commit aa051d3

31 files changed

+1054
-188
lines changed

MAINTAINERS

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,6 @@ F: arch/arm64/boot/dts/amd/amd-seattle-xgbe*.dtsi
10441044
F: drivers/net/ethernet/amd/xgbe/
10451045

10461046
AMD SENSOR FUSION HUB DRIVER
1047-
M: Nehal Shah <[email protected]>
10481047
M: Basavaraj Natikar <[email protected]>
10491048
10501049
S: Maintained
@@ -8766,6 +8765,14 @@ F: drivers/hid/hid-sensor-*
87668765
F: drivers/iio/*/hid-*
87678766
F: include/linux/hid-sensor-*
87688767

8768+
HID WACOM DRIVER
8769+
M: Ping Cheng <[email protected]>
8770+
M: Jason Gerecke <[email protected]>
8771+
8772+
S: Maintained
8773+
F: drivers/hid/wacom.h
8774+
F: drivers/hid/wacom_*
8775+
87698776
HIGH-RESOLUTION TIMERS, CLOCKEVENTS
87708777
M: Thomas Gleixner <[email protected]>
87718778

drivers/hid/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,14 @@ config HID_MAYFLASH
697697
Say Y here if you have HJZ Mayflash PS3 game controller adapters
698698
and want to enable force feedback support.
699699

700+
config HID_MEGAWORLD_FF
701+
tristate "Mega World based game controller force feedback support"
702+
depends on USB_HID
703+
select INPUT_FF_MEMLESS
704+
help
705+
Say Y here if you have a Mega World based game controller and want
706+
to have force feedback support for it.
707+
700708
config HID_REDRAGON
701709
tristate "Redragon keyboards"
702710
depends on HID

drivers/hid/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o
7777
obj-$(CONFIG_HID_MALTRON) += hid-maltron.o
7878
obj-$(CONFIG_HID_MCP2221) += hid-mcp2221.o
7979
obj-$(CONFIG_HID_MAYFLASH) += hid-mf.o
80+
obj-$(CONFIG_HID_MEGAWORLD_FF) += hid-megaworld.o
8081
obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o
8182
obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o
8283
obj-$(CONFIG_HID_MULTITOUCH) += hid-multitouch.o

drivers/hid/amd-sfh-hid/amd_sfh_client.c

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,24 @@ u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts)
141141
return sensor_sts;
142142
}
143143

144+
const char *get_sensor_name(int idx)
145+
{
146+
switch (idx) {
147+
case accel_idx:
148+
return "accelerometer";
149+
case gyro_idx:
150+
return "gyroscope";
151+
case mag_idx:
152+
return "magnetometer";
153+
case als_idx:
154+
return "ALS";
155+
case HPD_IDX:
156+
return "HPD";
157+
default:
158+
return "unknown sensor type";
159+
}
160+
}
161+
144162
int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
145163
{
146164
struct amd_input_data *in_data = &privdata->in_data;
@@ -219,13 +237,27 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
219237
(privdata, cl_data->sensor_idx[i], SENSOR_DISABLED);
220238
if (status != SENSOR_ENABLED)
221239
cl_data->sensor_sts[i] = SENSOR_DISABLED;
222-
dev_dbg(dev, "sid 0x%x status 0x%x\n",
223-
cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
240+
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
241+
cl_data->sensor_idx[i],
242+
get_sensor_name(cl_data->sensor_idx[i]),
243+
cl_data->sensor_sts[i]);
224244
goto cleanup;
225245
}
226246
}
227-
dev_dbg(dev, "sid 0x%x status 0x%x\n",
228-
cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
247+
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
248+
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
249+
cl_data->sensor_sts[i]);
250+
}
251+
if (privdata->mp2_ops->discovery_status &&
252+
privdata->mp2_ops->discovery_status(privdata) == 0) {
253+
amd_sfh_hid_client_deinit(privdata);
254+
for (i = 0; i < cl_data->num_hid_devices; i++) {
255+
devm_kfree(dev, cl_data->feature_report[i]);
256+
devm_kfree(dev, in_data->input_report[i]);
257+
devm_kfree(dev, cl_data->report_descr[i]);
258+
}
259+
dev_warn(dev, "Failed to discover, sensors not enabled\n");
260+
return -EOPNOTSUPP;
229261
}
230262
schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP));
231263
return 0;
@@ -257,8 +289,9 @@ int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata)
257289
(privdata, cl_data->sensor_idx[i], SENSOR_DISABLED);
258290
if (status != SENSOR_ENABLED)
259291
cl_data->sensor_sts[i] = SENSOR_DISABLED;
260-
dev_dbg(&privdata->pdev->dev, "stopping sid 0x%x status 0x%x\n",
261-
cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
292+
dev_dbg(&privdata->pdev->dev, "stopping sid 0x%x (%s) status 0x%x\n",
293+
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
294+
cl_data->sensor_sts[i]);
262295
}
263296
}
264297

drivers/hid/amd-sfh-hid/amd_sfh_hid.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/sched.h>
1313

1414
#include "amd_sfh_hid.h"
15+
#include "amd_sfh_pcie.h"
1516

1617
#define AMD_SFH_RESPONSE_TIMEOUT 1500
1718

@@ -120,6 +121,8 @@ static struct hid_ll_driver amdtp_hid_ll_driver = {
120121

121122
int amdtp_hid_probe(u32 cur_hid_dev, struct amdtp_cl_data *cli_data)
122123
{
124+
struct amd_mp2_dev *mp2 = container_of(cli_data->in_data, struct amd_mp2_dev, in_data);
125+
struct device *dev = &mp2->pdev->dev;
123126
struct hid_device *hid;
124127
struct amdtp_hid_data *hid_data;
125128
int rc;
@@ -141,10 +144,12 @@ int amdtp_hid_probe(u32 cur_hid_dev, struct amdtp_cl_data *cli_data)
141144

142145
hid->driver_data = hid_data;
143146
cli_data->hid_sensor_hubs[cur_hid_dev] = hid;
144-
hid->bus = BUS_AMD_AMDTP;
147+
strscpy(hid->phys, dev->driver ? dev->driver->name : dev_name(dev),
148+
sizeof(hid->phys));
149+
hid->bus = BUS_AMD_SFH;
145150
hid->vendor = AMD_SFH_HID_VENDOR;
146151
hid->product = AMD_SFH_HID_PRODUCT;
147-
snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", "hid-amdtp",
152+
snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", "hid-amdsfh",
148153
hid->vendor, hid->product);
149154

150155
rc = hid_add_device(hid);

drivers/hid/amd-sfh-hid/amd_sfh_hid.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#define AMDSFH_HID_H
1313

1414
#define MAX_HID_DEVICES 5
15-
#define BUS_AMD_AMDTP 0x20
1615
#define AMD_SFH_HID_VENDOR 0x1022
1716
#define AMD_SFH_HID_PRODUCT 0x0001
1817

drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ static int amd_sfh_irq_init_v2(struct amd_mp2_dev *privdata)
130130
return 0;
131131
}
132132

133+
static int amd_sfh_dis_sts_v2(struct amd_mp2_dev *privdata)
134+
{
135+
return (readl(privdata->mmio + AMD_P2C_MSG(1)) &
136+
SENSOR_DISCOVERY_STATUS_MASK) >> SENSOR_DISCOVERY_STATUS_SHIFT;
137+
}
138+
133139
void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info)
134140
{
135141
union sfh_cmd_param cmd_param;
@@ -245,6 +251,7 @@ static const struct amd_mp2_ops amd_sfh_ops_v2 = {
245251
.response = amd_sfh_wait_response_v2,
246252
.clear_intr = amd_sfh_clear_intr_v2,
247253
.init_intr = amd_sfh_irq_init_v2,
254+
.discovery_status = amd_sfh_dis_sts_v2,
248255
};
249256

250257
static const struct amd_mp2_ops amd_sfh_ops = {
@@ -346,8 +353,9 @@ static int __maybe_unused amd_mp2_pci_resume(struct device *dev)
346353
(mp2, cl_data->sensor_idx[i], SENSOR_ENABLED);
347354
if (status == SENSOR_ENABLED)
348355
cl_data->sensor_sts[i] = SENSOR_ENABLED;
349-
dev_dbg(dev, "resume sid 0x%x status 0x%x\n",
350-
cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
356+
dev_dbg(dev, "suspend sid 0x%x (%s) status 0x%x\n",
357+
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
358+
cl_data->sensor_sts[i]);
351359
}
352360
}
353361

@@ -371,8 +379,9 @@ static int __maybe_unused amd_mp2_pci_suspend(struct device *dev)
371379
(mp2, cl_data->sensor_idx[i], SENSOR_DISABLED);
372380
if (status != SENSOR_ENABLED)
373381
cl_data->sensor_sts[i] = SENSOR_DISABLED;
374-
dev_dbg(dev, "suspend sid 0x%x status 0x%x\n",
375-
cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
382+
dev_dbg(dev, "suspend sid 0x%x (%s) status 0x%x\n",
383+
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
384+
cl_data->sensor_sts[i]);
376385
}
377386
}
378387

drivers/hid/amd-sfh-hid/amd_sfh_pcie.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939

4040
#define AMD_SFH_IDLE_LOOP 200
4141

42+
#define SENSOR_DISCOVERY_STATUS_MASK GENMASK(5, 3)
43+
#define SENSOR_DISCOVERY_STATUS_SHIFT 3
44+
4245
/* SFH Command register */
4346
union sfh_cmd_base {
4447
u32 ul;
@@ -135,6 +138,7 @@ int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata);
135138
u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);
136139
void amd_mp2_suspend(struct amd_mp2_dev *mp2);
137140
void amd_mp2_resume(struct amd_mp2_dev *mp2);
141+
const char *get_sensor_name(int idx);
138142

139143
struct amd_mp2_ops {
140144
void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);
@@ -143,5 +147,6 @@ struct amd_mp2_ops {
143147
int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);
144148
void (*clear_intr)(struct amd_mp2_dev *privdata);
145149
int (*init_intr)(struct amd_mp2_dev *privdata);
150+
int (*discovery_status)(struct amd_mp2_dev *privdata);
146151
};
147152
#endif

drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static const u8 accel3_report_descriptor[] = {
179179
0xC0 /* HID end collection */
180180
};
181181

182-
const u8 gyro3_report_descriptor[] = {
182+
static const u8 gyro3_report_descriptor[] = {
183183
0x05, 0x20, /* Usage page */
184184
0x09, 0x76, /* Motion type Gyro3D */
185185
0xA1, 0x00, /* HID Collection (Physical) */
@@ -340,7 +340,7 @@ const u8 gyro3_report_descriptor[] = {
340340
0xC0, /* HID end collection */
341341
};
342342

343-
const u8 comp3_report_descriptor[] = {
343+
static const u8 comp3_report_descriptor[] = {
344344
0x05, 0x20, /* Usage page */
345345
0x09, 0x83, /* Motion type Orientation compass 3D */
346346
0xA1, 0x00, /* HID Collection (Physical) */
@@ -512,7 +512,7 @@ const u8 comp3_report_descriptor[] = {
512512
0xC0 /* HID end collection */
513513
};
514514

515-
const u8 als_report_descriptor[] = {
515+
static const u8 als_report_descriptor[] = {
516516
0x05, 0x20, /* HID usage page sensor */
517517
0x09, 0x41, /* HID usage sensor type Ambientlight */
518518
0xA1, 0x00, /* HID Collection (Physical) */

drivers/hid/hid-apple.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/module.h>
2222
#include <linux/slab.h>
2323
#include <linux/timer.h>
24+
#include <linux/string.h>
2425

2526
#include "hid-ids.h"
2627

@@ -35,16 +36,17 @@
3536
#define APPLE_NUMLOCK_EMULATION BIT(8)
3637
#define APPLE_RDESC_BATTERY BIT(9)
3738
#define APPLE_BACKLIGHT_CTL BIT(10)
39+
#define APPLE_IS_KEYCHRON BIT(11)
3840

3941
#define APPLE_FLAG_FKEY 0x01
4042

4143
#define HID_COUNTRY_INTERNATIONAL_ISO 13
4244
#define APPLE_BATTERY_TIMEOUT_MS 60000
4345

44-
static unsigned int fnmode = 1;
46+
static unsigned int fnmode = 3;
4547
module_param(fnmode, uint, 0644);
4648
MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "
47-
"[1] = fkeyslast, 2 = fkeysfirst)");
49+
"1 = fkeyslast, 2 = fkeysfirst, [3] = auto)");
4850

4951
static int iso_layout = -1;
5052
module_param(iso_layout, int, 0644);
@@ -349,6 +351,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
349351
const struct apple_key_translation *trans, *table;
350352
bool do_translate;
351353
u16 code = 0;
354+
unsigned int real_fnmode;
352355

353356
u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN);
354357

@@ -359,7 +362,13 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
359362
return 1;
360363
}
361364

362-
if (fnmode) {
365+
if (fnmode == 3) {
366+
real_fnmode = (asc->quirks & APPLE_IS_KEYCHRON) ? 2 : 1;
367+
} else {
368+
real_fnmode = fnmode;
369+
}
370+
371+
if (real_fnmode) {
363372
if (hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI ||
364373
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO ||
365374
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS ||
@@ -406,7 +415,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
406415

407416
if (!code) {
408417
if (trans->flags & APPLE_FLAG_FKEY) {
409-
switch (fnmode) {
418+
switch (real_fnmode) {
410419
case 1:
411420
do_translate = !asc->fn_on;
412421
break;
@@ -660,6 +669,11 @@ static int apple_input_configured(struct hid_device *hdev,
660669
asc->quirks &= ~APPLE_HAS_FN;
661670
}
662671

672+
if (strncmp(hdev->name, "Keychron", 8) == 0) {
673+
hid_info(hdev, "Keychron keyboard detected; function keys will default to fnmode=2 behavior\n");
674+
asc->quirks |= APPLE_IS_KEYCHRON;
675+
}
676+
663677
return 0;
664678
}
665679

0 commit comments

Comments
 (0)