Skip to content

Commit 34da76d

Browse files
committed
Merge tag 'for-linus-2023042601' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID updates from Jiri Kosina: - import a bunch of HID selftests from out-of-tree hid-tools project (Benjamin Tissoires) - drastically reducing Bluetooth disconnects on hid-nintendo driven devices (Daniel J. Ogorchock) - lazy initialization of battery interfaces in wacom driver (Jason Gerecke) - generic support for all Kye tablets (David Yang) - proper rumble queue overrun handling in hid-nintendo (Daniel J. Ogorchock) - support for ADC measurement in logitech-hidpp driver (Bastien Nocera) - reset GPIO support in i2c-hid (Hans de Goede) - improved handling of generic "Digitizer" usage (Jason Gerecke) - support for KEY_CAMERA_FOCUS (Feng Qi) - quirks for Apple Geyser 3 and Apple Geyser 4 (Alex Henrie) - assorted functional fixes and device ID additions * tag 'for-linus-2023042601' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (54 commits) HID: amd_sfh: Fix max supported HID devices HID: wacom: generic: Set battery quirk only when we see battery data HID: wacom: Lazy-init batteries HID: Ignore battery for ELAN touchscreen on ROG Flow X13 GV301RA HID: asus: explicitly include linux/leds.h HID: lg-g15: explicitly include linux/leds.h HID: steelseries: explicitly include linux/leds.h HID: apple: Set the tilde quirk flag on the Geyser 3 HID: apple: explicitly include linux/leds.h HID: mcp2221: fix get and get_direction for gpio HID: mcp2221: fix report layout for gpio get HID: wacom: Set a default resolution for older tablets HID: i2c-hid-of: Add reset GPIO support to i2c-hid-of HID: i2c-hid-of: Allow using i2c-hid-of on non OF platforms HID: i2c-hid-of: Consistenly use dev local variable in probe() HID: kye: Fix rdesc for kye tablets HID: amd_sfh: Support for additional light sensor HID: amd_sfh: Handle "no sensors" enabled for SFH1.1 HID: amd_sfh: Increase sensor command timeout for SFH1.1 HID: amd_sfh: Correct the stop all command ...
2 parents 725a345 + c3a6ef3 commit 34da76d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+9657
-625
lines changed

Documentation/ABI/testing/sysfs-bus-usb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,23 @@ Description:
166166
The file will be present for all speeds of USB devices, and will
167167
always read "no" for USB 1.1 and USB 2.0 devices.
168168

169+
What: /sys/bus/usb/devices/<INTERFACE>/wireless_status
170+
Date: February 2023
171+
Contact: Bastien Nocera <[email protected]>
172+
Description:
173+
Some USB devices use a USB receiver dongle to communicate
174+
wirelessly with their device using proprietary protocols. This
175+
attribute allows user-space to know whether the device is
176+
connected to its receiver dongle, and, for example, consider
177+
the device to be absent when choosing whether to show the
178+
device's battery, show a headset in a list of outputs, or show
179+
an on-screen keyboard if the only wireless keyboard is
180+
turned off.
181+
This attribute is not to be used to replace protocol specific
182+
statuses available in WWAN, WLAN/Wi-Fi, Bluetooth, etc.
183+
If the device does not use a receiver dongle with a wireless
184+
device, then this attribute will not exist.
185+
169186
What: /sys/bus/usb/devices/.../<hub_interface>/port<X>
170187
Date: August 2012
171188
Contact: Lan Tianyu <[email protected]>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ static const char *get_sensor_name(int idx)
147147
case mag_idx:
148148
return "magnetometer";
149149
case als_idx:
150+
case ACS_IDX: /* ambient color sensor */
150151
return "ALS";
151152
case HPD_IDX:
152153
return "HPD";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#ifndef AMDSFH_HID_H
1212
#define AMDSFH_HID_H
1313

14-
#define MAX_HID_DEVICES 5
14+
#define MAX_HID_DEVICES 6
1515
#define AMD_SFH_HID_VENDOR 0x1022
1616
#define AMD_SFH_HID_PRODUCT 0x0001
1717

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#define MAGNO_EN BIT(2)
3030
#define HPD_EN BIT(16)
3131
#define ALS_EN BIT(19)
32+
#define ACS_EN BIT(22)
3233

3334
static int sensor_mask_override = -1;
3435
module_param_named(sensor_mask, sensor_mask_override, int, 0444);
@@ -233,6 +234,9 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
233234
if (HPD_EN & activestatus)
234235
sensor_id[num_of_sensors++] = HPD_IDX;
235236

237+
if (ACS_EN & activestatus)
238+
sensor_id[num_of_sensors++] = ACS_IDX;
239+
236240
return num_of_sensors;
237241
}
238242

@@ -367,6 +371,14 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
367371
return devm_add_action_or_reset(&pdev->dev, privdata->mp2_ops->remove, privdata);
368372
}
369373

374+
static void amd_sfh_shutdown(struct pci_dev *pdev)
375+
{
376+
struct amd_mp2_dev *mp2 = pci_get_drvdata(pdev);
377+
378+
if (mp2 && mp2->mp2_ops)
379+
mp2->mp2_ops->stop_all(mp2);
380+
}
381+
370382
static int __maybe_unused amd_mp2_pci_resume(struct device *dev)
371383
{
372384
struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
@@ -401,6 +413,7 @@ static struct pci_driver amd_mp2_pci_driver = {
401413
.id_table = amd_mp2_pci_tbl,
402414
.probe = amd_mp2_pci_probe,
403415
.driver.pm = &amd_mp2_pm_ops,
416+
.shutdown = amd_sfh_shutdown,
404417
};
405418
module_pci_driver(amd_mp2_pci_driver);
406419

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define V2_STATUS 0x2
2424

2525
#define HPD_IDX 16
26+
#define ACS_IDX 22
2627

2728
#define SENSOR_DISCOVERY_STATUS_MASK GENMASK(5, 3)
2829
#define SENSOR_DISCOVERY_STATUS_SHIFT 3

drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static int get_report_descriptor(int sensor_idx, u8 *rep_desc)
4848
sizeof(comp3_report_descriptor));
4949
break;
5050
case als_idx: /* ambient light sensor */
51+
case ACS_IDX: /* ambient color sensor */
5152
memset(rep_desc, 0, sizeof(als_report_descriptor));
5253
memcpy(rep_desc, als_report_descriptor,
5354
sizeof(als_report_descriptor));
@@ -97,6 +98,7 @@ static u32 get_descr_sz(int sensor_idx, int descriptor_name)
9798
}
9899
break;
99100
case als_idx:
101+
case ACS_IDX: /* ambient color sensor */
100102
switch (descriptor_name) {
101103
case descr_size:
102104
return sizeof(als_report_descriptor);
@@ -174,6 +176,7 @@ static u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report)
174176
report_size = sizeof(magno_feature);
175177
break;
176178
case als_idx: /* ambient light sensor */
179+
case ACS_IDX: /* ambient color sensor */
177180
get_common_features(&als_feature.common_property, report_id);
178181
als_feature.als_change_sesnitivity = HID_DEFAULT_SENSITIVITY;
179182
als_feature.als_sensitivity_min = HID_DEFAULT_MIN_VALUE;
@@ -245,6 +248,7 @@ static u8 get_input_report(u8 current_index, int sensor_idx, int report_id,
245248
report_size = sizeof(magno_input);
246249
break;
247250
case als_idx: /* Als */
251+
case ACS_IDX: /* ambient color sensor */
248252
get_common_inputs(&als_input.common_property, report_id);
249253
/* For ALS ,V2 Platforms uses C2P_MSG5 register instead of DRAM access method */
250254
if (supported_input == V2_STATUS)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
218218
OFFSET_SENSOR_DATA_DEFAULT;
219219
memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data));
220220
get_common_inputs(&als_input.common_property, report_id);
221-
als_input.illuminance_value = als_data.lux;
221+
als_input.illuminance_value = float_to_int(als_data.lux);
222222
report_size = sizeof(als_input);
223223
memcpy(input_report, &als_input, sizeof(als_input));
224224
break;

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
112112
cl_data->num_hid_devices = amd_sfh_get_sensor_num(privdata, &cl_data->sensor_idx[0]);
113113
if (cl_data->num_hid_devices == 0)
114114
return -ENODEV;
115+
cl_data->is_any_sensor_enabled = false;
115116

116117
INIT_DELAYED_WORK(&cl_data->work, amd_sfh_work);
117118
INIT_DELAYED_WORK(&cl_data->work_buffer, amd_sfh_work_buffer);
@@ -170,6 +171,7 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
170171
status = (status == 0) ? SENSOR_ENABLED : SENSOR_DISABLED;
171172

172173
if (status == SENSOR_ENABLED) {
174+
cl_data->is_any_sensor_enabled = true;
173175
cl_data->sensor_sts[i] = SENSOR_ENABLED;
174176
rc = amdtp_hid_probe(i, cl_data);
175177
if (rc) {
@@ -186,12 +188,21 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
186188
cl_data->sensor_sts[i]);
187189
goto cleanup;
188190
}
191+
} else {
192+
cl_data->sensor_sts[i] = SENSOR_DISABLED;
189193
}
190194
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
191195
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
192196
cl_data->sensor_sts[i]);
193197
}
194198

199+
if (!cl_data->is_any_sensor_enabled) {
200+
dev_warn(dev, "Failed to discover, sensors not enabled is %d\n",
201+
cl_data->is_any_sensor_enabled);
202+
rc = -EOPNOTSUPP;
203+
goto cleanup;
204+
}
205+
195206
schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP));
196207
return 0;
197208

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ static int amd_sfh_wait_response(struct amd_mp2_dev *mp2, u8 sid, u32 cmd_id)
1616
{
1717
struct sfh_cmd_response cmd_resp;
1818

19-
/* Get response with status within a max of 1600 ms timeout */
19+
/* Get response with status within a max of 10000 ms timeout */
2020
if (!readl_poll_timeout(mp2->mmio + AMD_P2C_MSG(0), cmd_resp.resp,
2121
(cmd_resp.response.response == 0 &&
2222
cmd_resp.response.cmd_id == cmd_id && (sid == 0xff ||
23-
cmd_resp.response.sensor_id == sid)), 500, 1600000))
23+
cmd_resp.response.sensor_id == sid)), 500, 10000000))
2424
return cmd_resp.response.response;
2525

2626
return -1;
@@ -33,6 +33,7 @@ static void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor
3333
cmd_base.ul = 0;
3434
cmd_base.cmd.cmd_id = ENABLE_SENSOR;
3535
cmd_base.cmd.intr_disable = 0;
36+
cmd_base.cmd.sub_cmd_value = 1;
3637
cmd_base.cmd.sensor_id = info.sensor_idx;
3738

3839
writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG(0));
@@ -45,6 +46,7 @@ static void amd_stop_sensor(struct amd_mp2_dev *privdata, u16 sensor_idx)
4546
cmd_base.ul = 0;
4647
cmd_base.cmd.cmd_id = DISABLE_SENSOR;
4748
cmd_base.cmd.intr_disable = 0;
49+
cmd_base.cmd.sub_cmd_value = 1;
4850
cmd_base.cmd.sensor_id = sensor_idx;
4951

5052
writeq(0x0, privdata->mmio + AMD_C2P_MSG(1));
@@ -56,8 +58,10 @@ static void amd_stop_all_sensor(struct amd_mp2_dev *privdata)
5658
struct sfh_cmd_base cmd_base;
5759

5860
cmd_base.ul = 0;
59-
cmd_base.cmd.cmd_id = STOP_ALL_SENSORS;
61+
cmd_base.cmd.cmd_id = DISABLE_SENSOR;
6062
cmd_base.cmd.intr_disable = 0;
63+
/* 0xf indicates all sensors */
64+
cmd_base.cmd.sensor_id = 0xf;
6165

6266
writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG(0));
6367
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ struct sfh_cmd_base {
3333
struct {
3434
u32 sensor_id : 4;
3535
u32 cmd_id : 4;
36-
u32 sub_cmd_id : 6;
37-
u32 length : 12;
38-
u32 rsvd : 5;
36+
u32 sub_cmd_id : 8;
37+
u32 sub_cmd_value : 12;
38+
u32 rsvd : 3;
3939
u32 intr_disable : 1;
4040
} cmd;
4141
};
@@ -133,7 +133,7 @@ struct sfh_mag_data {
133133

134134
struct sfh_als_data {
135135
struct sfh_common_data commondata;
136-
u16 lux;
136+
u32 lux;
137137
};
138138

139139
struct hpd_status {

0 commit comments

Comments
 (0)