Skip to content

Commit fef018d

Browse files
committed
Merge tag 'hid-for-linus-2024010801' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID updates from Jiri Kosina: - assorted functional fixes for hid-steam ported from SteamOS betas (Vicki Pfau) - fix for custom sensor-hub sensors (hinge angle sensor and LISS sensors) not working (Yauhen Kharuzhy) - functional fix for handling Confidence in Wacom driver (Jason Gerecke) - support for Ilitek ili2901 touchscreen (Zhengqiao Xia) - power management fix for Wacom userspace battery exporting (Tatsunosuke Tobita) - rework of wait-for-reset in order to reduce the need for I2C_HID_QUIRK_NO_IRQ_AFTER_RESET qurk; the success rate is now 50% better, but there are still further improvements to be made (Hans de Goede) - greatly improved coverage of Tablets in hid-selftests (Benjamin Tissoires) - support for Nintendo NSO controllers -- SNES, Genesis and N64 (Ryan McClelland) - support for controlling mcp2200 GPIOs (Johannes Roith) - power management improvement for EHL OOB wakeup in intel-ish (Kai-Heng Feng) - other assorted device-specific fixes and code cleanups * tag 'hid-for-linus-2024010801' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (53 commits) HID: amd_sfh: Add a new interface for exporting ALS data HID: amd_sfh: Add a new interface for exporting HPD data HID: amd_sfh: rename float_to_int() to amd_sfh_float_to_int() HID: i2c-hid: elan: Add ili2901 timing dt-bindings: HID: i2c-hid: elan: Introduce Ilitek ili2901 HID: bpf: make bus_type const in struct hid_bpf_ops HID: make ishtp_cl_bus_type const HID: make hid_bus_type const HID: hid-steam: Add gamepad-only mode switched to by holding options HID: hid-steam: Better handling of serial number length HID: hid-steam: Update list of identifiers from SDL HID: hid-steam: Make client_opened a counter HID: hid-steam: Clean up locking HID: hid-steam: Disable watchdog instead of using a heartbeat HID: hid-steam: Avoid overwriting smoothing parameter HID: magicmouse: fix kerneldoc for struct magicmouse_sc HID: sensor-hub: Enable hid core report processing for all devices HID: wacom: Add additional tests of confidence behavior HID: wacom: Correct behavior when processing some confidence == false touches HID: nintendo: add support for nso controllers ...
2 parents d97a784 + 0b43615 commit fef018d

37 files changed

+2834
-1050
lines changed

Documentation/devicetree/bindings/input/elan,ekth6915.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ allOf:
1818

1919
properties:
2020
compatible:
21-
items:
22-
- const: elan,ekth6915
21+
enum:
22+
- elan,ekth6915
23+
- ilitek,ili2901
2324

2425
reg:
2526
const: 0x10

drivers/hid/Kconfig

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -761,14 +761,15 @@ config HID_MULTITOUCH
761761
module will be called hid-multitouch.
762762

763763
config HID_NINTENDO
764-
tristate "Nintendo Joy-Con and Pro Controller support"
764+
tristate "Nintendo Joy-Con, NSO, and Pro Controller support"
765765
depends on NEW_LEDS
766766
depends on LEDS_CLASS
767767
select POWER_SUPPLY
768768
help
769-
Adds support for the Nintendo Switch Joy-Cons and Pro Controller.
769+
Adds support for the Nintendo Switch Joy-Cons, NSO, Pro Controller.
770770
All controllers support bluetooth, and the Pro Controller also supports
771-
its USB mode.
771+
its USB mode. This also includes support for the Nintendo Switch Online
772+
Controllers which include the Genesis, SNES, and N64 controllers.
772773

773774
To compile this driver as a module, choose M here: the
774775
module will be called hid-nintendo.
@@ -779,9 +780,9 @@ config NINTENDO_FF
779780
select INPUT_FF_MEMLESS
780781
help
781782
Say Y here if you have a Nintendo Switch controller and want to enable
782-
force feedback support for it. This works for both joy-cons and the pro
783-
controller. For the pro controller, both rumble motors can be controlled
784-
individually.
783+
force feedback support for it. This works for both joy-cons, the pro
784+
controller, and the NSO N64 controller. For the pro controller, both
785+
rumble motors can be controlled individually.
785786

786787
config HID_NTI
787788
tristate "NTI keyboard adapters"
@@ -1296,6 +1297,15 @@ config HID_ALPS
12961297
Say Y here if you have a Alps touchpads over i2c-hid or usbhid
12971298
and want support for its special functionalities.
12981299

1300+
config HID_MCP2200
1301+
tristate "Microchip MCP2200 HID USB-to-GPIO bridge"
1302+
depends on USB_HID && GPIOLIB
1303+
help
1304+
Provides GPIO functionality over USB-HID through MCP2200 device.
1305+
1306+
To compile this driver as a module, choose M here: the module
1307+
will be called hid-mcp2200.ko.
1308+
12991309
config HID_MCP2221
13001310
tristate "Microchip MCP2221 HID USB-to-I2C/SMbus host support"
13011311
depends on USB_HID && I2C

drivers/hid/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ obj-$(CONFIG_HID_LOGITECH_HIDPP) += hid-logitech-hidpp.o
7979
obj-$(CONFIG_HID_MACALLY) += hid-macally.o
8080
obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o
8181
obj-$(CONFIG_HID_MALTRON) += hid-maltron.o
82+
obj-$(CONFIG_HID_MCP2200) += hid-mcp2200.o
8283
obj-$(CONFIG_HID_MCP2221) += hid-mcp2221.o
8384
obj-$(CONFIG_HID_MAYFLASH) += hid-mf.o
8485
obj-$(CONFIG_HID_MEGAWORLD_FF) += hid-megaworld.o

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ struct amd_mp2_sensor_info {
3737
dma_addr_t dma_address;
3838
};
3939

40+
struct sfh_dev_status {
41+
bool is_hpd_present;
42+
bool is_als_present;
43+
};
44+
4045
struct amd_mp2_dev {
4146
struct pci_dev *pdev;
4247
struct amdtp_cl_data *cl_data;
@@ -47,6 +52,7 @@ struct amd_mp2_dev {
4752
struct amd_input_data in_data;
4853
/* mp2 active control status */
4954
u32 mp2_acs;
55+
struct sfh_dev_status dev_en;
5056
};
5157

5258
struct amd_mp2_ops {

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void get_common_inputs(struct common_input_property *common, int report_i
132132
common->event_type = HID_USAGE_SENSOR_EVENT_DATA_UPDATED_ENUM;
133133
}
134134

135-
static int float_to_int(u32 flt32_val)
135+
int amd_sfh_float_to_int(u32 flt32_val)
136136
{
137137
int fraction, shift, mantissa, sign, exp, zeropre;
138138

@@ -201,9 +201,9 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
201201
OFFSET_SENSOR_DATA_DEFAULT;
202202
memcpy_fromio(&accel_data, sensoraddr, sizeof(struct sfh_accel_data));
203203
get_common_inputs(&acc_input.common_property, report_id);
204-
acc_input.in_accel_x_value = float_to_int(accel_data.acceldata.x) / 100;
205-
acc_input.in_accel_y_value = float_to_int(accel_data.acceldata.y) / 100;
206-
acc_input.in_accel_z_value = float_to_int(accel_data.acceldata.z) / 100;
204+
acc_input.in_accel_x_value = amd_sfh_float_to_int(accel_data.acceldata.x) / 100;
205+
acc_input.in_accel_y_value = amd_sfh_float_to_int(accel_data.acceldata.y) / 100;
206+
acc_input.in_accel_z_value = amd_sfh_float_to_int(accel_data.acceldata.z) / 100;
207207
memcpy(input_report, &acc_input, sizeof(acc_input));
208208
report_size = sizeof(acc_input);
209209
break;
@@ -212,9 +212,9 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
212212
OFFSET_SENSOR_DATA_DEFAULT;
213213
memcpy_fromio(&gyro_data, sensoraddr, sizeof(struct sfh_gyro_data));
214214
get_common_inputs(&gyro_input.common_property, report_id);
215-
gyro_input.in_angel_x_value = float_to_int(gyro_data.gyrodata.x) / 1000;
216-
gyro_input.in_angel_y_value = float_to_int(gyro_data.gyrodata.y) / 1000;
217-
gyro_input.in_angel_z_value = float_to_int(gyro_data.gyrodata.z) / 1000;
215+
gyro_input.in_angel_x_value = amd_sfh_float_to_int(gyro_data.gyrodata.x) / 1000;
216+
gyro_input.in_angel_y_value = amd_sfh_float_to_int(gyro_data.gyrodata.y) / 1000;
217+
gyro_input.in_angel_z_value = amd_sfh_float_to_int(gyro_data.gyrodata.z) / 1000;
218218
memcpy(input_report, &gyro_input, sizeof(gyro_input));
219219
report_size = sizeof(gyro_input);
220220
break;
@@ -223,9 +223,9 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
223223
OFFSET_SENSOR_DATA_DEFAULT;
224224
memcpy_fromio(&mag_data, sensoraddr, sizeof(struct sfh_mag_data));
225225
get_common_inputs(&magno_input.common_property, report_id);
226-
magno_input.in_magno_x = float_to_int(mag_data.magdata.x) / 100;
227-
magno_input.in_magno_y = float_to_int(mag_data.magdata.y) / 100;
228-
magno_input.in_magno_z = float_to_int(mag_data.magdata.z) / 100;
226+
magno_input.in_magno_x = amd_sfh_float_to_int(mag_data.magdata.x) / 100;
227+
magno_input.in_magno_y = amd_sfh_float_to_int(mag_data.magdata.y) / 100;
228+
magno_input.in_magno_z = amd_sfh_float_to_int(mag_data.magdata.z) / 100;
229229
magno_input.in_magno_accuracy = mag_data.accuracy / 100;
230230
memcpy(input_report, &magno_input, sizeof(magno_input));
231231
report_size = sizeof(magno_input);
@@ -235,13 +235,15 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
235235
OFFSET_SENSOR_DATA_DEFAULT;
236236
memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data));
237237
get_common_inputs(&als_input.common_property, report_id);
238-
als_input.illuminance_value = float_to_int(als_data.lux);
238+
als_input.illuminance_value = amd_sfh_float_to_int(als_data.lux);
239239

240240
memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info));
241241
if (binfo.sbase.s_prop[ALS_IDX].sf.feat & 0x2) {
242242
als_input.light_color_temp = als_data.light_color_temp;
243-
als_input.chromaticity_x_value = float_to_int(als_data.chromaticity_x);
244-
als_input.chromaticity_y_value = float_to_int(als_data.chromaticity_y);
243+
als_input.chromaticity_x_value =
244+
amd_sfh_float_to_int(als_data.chromaticity_x);
245+
als_input.chromaticity_y_value =
246+
amd_sfh_float_to_int(als_data.chromaticity_y);
245247
}
246248

247249
report_size = sizeof(als_input);

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ static int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata)
7373
int i, status;
7474

7575
for (i = 0; i < cl_data->num_hid_devices; i++) {
76+
switch (cl_data->sensor_idx[i]) {
77+
case HPD_IDX:
78+
privdata->dev_en.is_hpd_present = false;
79+
break;
80+
case ALS_IDX:
81+
privdata->dev_en.is_als_present = false;
82+
break;
83+
}
84+
7685
if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
7786
privdata->mp2_ops->stop(privdata, cl_data->sensor_idx[i]);
7887
status = amd_sfh_wait_for_response
@@ -178,6 +187,14 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
178187
rc = amdtp_hid_probe(i, cl_data);
179188
if (rc)
180189
goto cleanup;
190+
switch (cl_data->sensor_idx[i]) {
191+
case HPD_IDX:
192+
privdata->dev_en.is_hpd_present = true;
193+
break;
194+
case ALS_IDX:
195+
privdata->dev_en.is_als_present = true;
196+
break;
197+
}
181198
}
182199
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
183200
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
@@ -259,6 +276,7 @@ static void amd_mp2_pci_remove(void *privdata)
259276
{
260277
struct amd_mp2_dev *mp2 = privdata;
261278

279+
sfh_deinit_emp2();
262280
amd_sfh_hid_client_deinit(privdata);
263281
mp2->mp2_ops->stop_all(mp2);
264282
pci_intx(mp2->pdev, false);
@@ -311,12 +329,14 @@ int amd_sfh1_1_init(struct amd_mp2_dev *mp2)
311329

312330
rc = amd_sfh_irq_init(mp2);
313331
if (rc) {
332+
sfh_deinit_emp2();
314333
dev_err(dev, "amd_sfh_irq_init failed\n");
315334
return rc;
316335
}
317336

318337
rc = amd_sfh1_1_hid_client_init(mp2);
319338
if (rc) {
339+
sfh_deinit_emp2();
320340
dev_err(dev, "amd_sfh1_1_hid_client_init failed\n");
321341
return rc;
322342
}

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
*
88
* Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
99
*/
10+
#include <linux/amd-pmf-io.h>
1011
#include <linux/io-64-nonatomic-lo-hi.h>
1112
#include <linux/iopoll.h>
1213

1314
#include "amd_sfh_interface.h"
1415

16+
static struct amd_mp2_dev *emp2;
17+
1518
static int amd_sfh_wait_response(struct amd_mp2_dev *mp2, u8 sid, u32 cmd_id)
1619
{
1720
struct sfh_cmd_response cmd_resp;
@@ -73,7 +76,63 @@ static struct amd_mp2_ops amd_sfh_ops = {
7376
.response = amd_sfh_wait_response,
7477
};
7578

79+
void sfh_deinit_emp2(void)
80+
{
81+
emp2 = NULL;
82+
}
83+
7684
void sfh_interface_init(struct amd_mp2_dev *mp2)
7785
{
7886
mp2->mp2_ops = &amd_sfh_ops;
87+
emp2 = mp2;
88+
}
89+
90+
static int amd_sfh_hpd_info(u8 *user_present)
91+
{
92+
struct hpd_status hpdstatus;
93+
94+
if (!user_present)
95+
return -EINVAL;
96+
97+
if (!emp2 || !emp2->dev_en.is_hpd_present)
98+
return -ENODEV;
99+
100+
hpdstatus.val = readl(emp2->mmio + AMD_C2P_MSG(4));
101+
*user_present = hpdstatus.shpd.presence;
102+
103+
return 0;
104+
}
105+
106+
static int amd_sfh_als_info(u32 *ambient_light)
107+
{
108+
struct sfh_als_data als_data;
109+
void __iomem *sensoraddr;
110+
111+
if (!ambient_light)
112+
return -EINVAL;
113+
114+
if (!emp2 || !emp2->dev_en.is_als_present)
115+
return -ENODEV;
116+
117+
sensoraddr = emp2->vsbase +
118+
(ALS_IDX * SENSOR_DATA_MEM_SIZE_DEFAULT) +
119+
OFFSET_SENSOR_DATA_DEFAULT;
120+
memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data));
121+
*ambient_light = amd_sfh_float_to_int(als_data.lux);
122+
123+
return 0;
124+
}
125+
126+
int amd_get_sfh_info(struct amd_sfh_info *sfh_info, enum sfh_message_type op)
127+
{
128+
if (sfh_info) {
129+
switch (op) {
130+
case MT_HPD:
131+
return amd_sfh_hpd_info(&sfh_info->user_present);
132+
case MT_ALS:
133+
return amd_sfh_als_info(&sfh_info->ambient_light);
134+
}
135+
}
136+
return -EINVAL;
79137
}
138+
EXPORT_SYMBOL_GPL(amd_get_sfh_info);

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,7 @@ struct hpd_status {
165165
};
166166

167167
void sfh_interface_init(struct amd_mp2_dev *mp2);
168+
void sfh_deinit_emp2(void);
168169
void amd_sfh1_1_set_desc_ops(struct amd_mp2_ops *mp2_ops);
170+
int amd_sfh_float_to_int(u32 flt32_val);
169171
#endif

drivers/hid/hid-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2749,7 +2749,7 @@ static int hid_uevent(const struct device *dev, struct kobj_uevent_env *env)
27492749
return 0;
27502750
}
27512751

2752-
struct bus_type hid_bus_type = {
2752+
const struct bus_type hid_bus_type = {
27532753
.name = "hid",
27542754
.dev_groups = hid_dev_groups,
27552755
.drv_groups = hid_drv_groups,

drivers/hid/hid-ids.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@
916916
#define USB_DEVICE_ID_PICK16F1454 0x0042
917917
#define USB_DEVICE_ID_PICK16F1454_V2 0xf2f7
918918
#define USB_DEVICE_ID_LUXAFOR 0xf372
919+
#define USB_DEVICE_ID_MCP2200 0x00df
919920
#define USB_DEVICE_ID_MCP2221 0x00dd
920921

921922
#define USB_VENDOR_ID_MICROSOFT 0x045e
@@ -987,7 +988,10 @@
987988
#define USB_DEVICE_ID_NINTENDO_JOYCONL 0x2006
988989
#define USB_DEVICE_ID_NINTENDO_JOYCONR 0x2007
989990
#define USB_DEVICE_ID_NINTENDO_PROCON 0x2009
990-
#define USB_DEVICE_ID_NINTENDO_CHRGGRIP 0x200E
991+
#define USB_DEVICE_ID_NINTENDO_CHRGGRIP 0x200e
992+
#define USB_DEVICE_ID_NINTENDO_SNESCON 0x2017
993+
#define USB_DEVICE_ID_NINTENDO_GENCON 0x201e
994+
#define USB_DEVICE_ID_NINTENDO_N64CON 0x2019
991995

992996
#define USB_VENDOR_ID_NOVATEK 0x0603
993997
#define USB_DEVICE_ID_NOVATEK_PCT 0x0600

0 commit comments

Comments
 (0)