Skip to content

Commit

Permalink
Merge tag 'for-linus-2022080201' of git://git.kernel.org/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x/kernel/git/hid/hid

Pull HID updates from Jiri Kosina:

 - support for AMD SOCs using SFH1.1 memory access (Basavaraj Natikar)

 - XP-PEN Deco L support (José Expósito)

 - support for Elan eKTH6915 touchscreens (Douglas Anderson)

 - other small assorted fixes and device ID additions

* tag 'for-linus-2022080201' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (39 commits)
  HID: amd_sfh: Handle condition of "no sensors"
  HID: amd_sfh: Fix implicit declaration error on i386
  HID: apple: Add "GANSS" to the non-Apple list
  HID: alps: Declare U1_UNICORN_LEGACY support
  HID: wacom: Force pen out of prox if no events have been received in a while
  HID: nintendo: Add missing array termination
  HID: lg-g15: Fix comment typo
  HID: amd_sfh: Implement SFH1.1 functionality
  HID: amd_sfh: Move interrupt handling to common interface
  HID: amd_sfh: Move amd_sfh_work to common interface
  HID: amd_sfh: Move global functions to static
  HID: amd_sfh: Add remove operation in amd_mp2_ops
  HID: amd_sfh: Add PM operations in amd_mp2_ops
  HID: amd_sfh: Add descriptor operations in amd_mp2_ops
  HID: amd_sfh: Move request_list variable to client data
  HID: amd_sfh: Move request_list struct to header file
  HID: amd_sfh: Move common macros and structures
  HID: amd_sfh: Add NULL check for hid device
  HID: core: remove unneeded assignment in hid_process_report()
  ID: intel-ish-hid: hid-client: drop unexpected word "the" in the comments
  ...
  • Loading branch information
Linus Torvalds committed Aug 5, 2022
2 parents c040862 + a60885b commit 8d9420c
Show file tree
Hide file tree
Showing 42 changed files with 2,066 additions and 208 deletions.
65 changes: 65 additions & 0 deletions Documentation/devicetree/bindings/input/elan,ekth6915.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/input/elan,ekth6915.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Elan eKTH6915 touchscreen controller

maintainers:
- Douglas Anderson <dianders@chromium.org>

description:
Supports the Elan eKTH6915 touchscreen controller.
This touchscreen controller uses the i2c-hid protocol with a reset GPIO.

properties:
compatible:
items:
- const: elan,ekth6915

reg:
const: 0x10

interrupts:
maxItems: 1

reset-gpios:
description: Reset GPIO; not all touchscreens using eKTH6915 hook this up.

vcc33-supply:
description: The 3.3V supply to the touchscreen.

vccio-supply:
description:
The IO supply to the touchscreen. Need not be specified if this is the
same as the 3.3V supply.

required:
- compatible
- reg
- interrupts
- vcc33-supply

additionalProperties: false

examples:
- |
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
ap_ts: touchscreen@10 {
compatible = "elan,ekth6915";
reg = <0x10>;
interrupt-parent = <&tlmm>;
interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
reset-gpios = <&tlmm 8 GPIO_ACTIVE_LOW>;
vcc33-supply = <&pp3300_ts>;
};
};
5 changes: 5 additions & 0 deletions drivers/hid/.kunitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CONFIG_KUNIT=y
CONFIG_USB=y
CONFIG_USB_HID=y
CONFIG_HID_UCLOGIC=y
CONFIG_HID_KUNIT_TEST=y
16 changes: 16 additions & 0 deletions drivers/hid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,22 @@ config HID_MCP2221
To compile this driver as a module, choose M here: the module
will be called hid-mcp2221.ko.

config HID_KUNIT_TEST
bool "KUnit tests for HID" if !KUNIT_ALL_TESTS
depends on KUNIT=y
depends on HID_UCLOGIC
default KUNIT_ALL_TESTS
help
This builds unit tests for HID. This option is not useful for
distributions or general kernels, but only for kernel
developers working on HID and associated drivers.

For more information on KUnit and unit tests in general,
please refer to the KUnit documentation in
Documentation/dev-tools/kunit/.

If in doubt, say "N".

endmenu

endif # HID
Expand Down
3 changes: 3 additions & 0 deletions drivers/hid/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ obj-$(CONFIG_HID_WIIMOTE) += hid-wiimote.o
obj-$(CONFIG_HID_SENSOR_HUB) += hid-sensor-hub.o
obj-$(CONFIG_HID_SENSOR_CUSTOM_SENSOR) += hid-sensor-custom.o

obj-$(CONFIG_HID_KUNIT_TEST) += hid-uclogic-rdesc.o \
hid-uclogic-rdesc-test.o

obj-$(CONFIG_USB_HID) += usbhid/
obj-$(CONFIG_USB_MOUSE) += usbhid/
obj-$(CONFIG_USB_KBD) += usbhid/
Expand Down
3 changes: 3 additions & 0 deletions drivers/hid/amd-sfh-hid/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ amd_sfh-objs := amd_sfh_hid.o
amd_sfh-objs += amd_sfh_client.o
amd_sfh-objs += amd_sfh_pcie.o
amd_sfh-objs += hid_descriptor/amd_sfh_hid_desc.o
amd_sfh-objs += sfh1_1/amd_sfh_init.o
amd_sfh-objs += sfh1_1/amd_sfh_interface.o
amd_sfh-objs += sfh1_1/amd_sfh_desc.o

ccflags-y += -I $(srctree)/$(src)/
117 changes: 85 additions & 32 deletions drivers/hid/amd-sfh-hid/amd_sfh_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@
#include "amd_sfh_pcie.h"
#include "amd_sfh_hid.h"


struct request_list {
struct hid_device *hid;
struct list_head list;
u8 report_id;
u8 sensor_idx;
u8 report_type;
u8 current_index;
};

static struct request_list req_list;

void amd_sfh_set_report(struct hid_device *hid, int report_id,
int report_type)
{
Expand All @@ -50,6 +38,7 @@ int amd_sfh_get_report(struct hid_device *hid, int report_id, int report_type)
{
struct amdtp_hid_data *hid_data = hid->driver_data;
struct amdtp_cl_data *cli_data = hid_data->cli_data;
struct request_list *req_list = &cli_data->req_list;
int i;

for (i = 0; i < cli_data->num_hid_devices; i++) {
Expand All @@ -66,34 +55,39 @@ int amd_sfh_get_report(struct hid_device *hid, int report_id, int report_type)
new->report_id = report_id;
cli_data->report_id[i] = report_id;
cli_data->request_done[i] = false;
list_add(&new->list, &req_list.list);
list_add(&new->list, &req_list->list);
break;
}
}
schedule_delayed_work(&cli_data->work, 0);
return 0;
}

static void amd_sfh_work(struct work_struct *work)
void amd_sfh_work(struct work_struct *work)
{
struct amdtp_cl_data *cli_data = container_of(work, struct amdtp_cl_data, work.work);
struct request_list *req_list = &cli_data->req_list;
struct amd_input_data *in_data = cli_data->in_data;
struct request_list *req_node;
u8 current_index, sensor_index;
struct amd_mp2_ops *mp2_ops;
struct amd_mp2_dev *mp2;
u8 report_id, node_type;
u8 report_size = 0;

req_node = list_last_entry(&req_list.list, struct request_list, list);
req_node = list_last_entry(&req_list->list, struct request_list, list);
list_del(&req_node->list);
current_index = req_node->current_index;
sensor_index = req_node->sensor_idx;
report_id = req_node->report_id;
node_type = req_node->report_type;
kfree(req_node);

mp2 = container_of(in_data, struct amd_mp2_dev, in_data);
mp2_ops = mp2->mp2_ops;
if (node_type == HID_FEATURE_REPORT) {
report_size = get_feature_report(sensor_index, report_id,
cli_data->feature_report[current_index]);
report_size = mp2_ops->get_feat_rep(sensor_index, report_id,
cli_data->feature_report[current_index]);
if (report_size)
hid_input_report(cli_data->hid_sensor_hubs[current_index],
cli_data->report_type[current_index],
Expand All @@ -102,7 +96,7 @@ static void amd_sfh_work(struct work_struct *work)
pr_err("AMDSFH: Invalid report size\n");

} else if (node_type == HID_INPUT_REPORT) {
report_size = get_input_report(current_index, sensor_index, report_id, in_data);
report_size = mp2_ops->get_in_rep(current_index, sensor_index, report_id, in_data);
if (report_size)
hid_input_report(cli_data->hid_sensor_hubs[current_index],
cli_data->report_type[current_index],
Expand All @@ -115,33 +109,35 @@ static void amd_sfh_work(struct work_struct *work)
amdtp_hid_wakeup(cli_data->hid_sensor_hubs[current_index]);
}

static void amd_sfh_work_buffer(struct work_struct *work)
void amd_sfh_work_buffer(struct work_struct *work)
{
struct amdtp_cl_data *cli_data = container_of(work, struct amdtp_cl_data, work_buffer.work);
struct amd_input_data *in_data = cli_data->in_data;
struct amd_mp2_dev *mp2;
u8 report_size;
int i;

for (i = 0; i < cli_data->num_hid_devices; i++) {
if (cli_data->sensor_sts[i] == SENSOR_ENABLED) {
report_size = get_input_report
(i, cli_data->sensor_idx[i], cli_data->report_id[i], in_data);
mp2 = container_of(in_data, struct amd_mp2_dev, in_data);
report_size = mp2->mp2_ops->get_in_rep(i, cli_data->sensor_idx[i],
cli_data->report_id[i], in_data);
hid_input_report(cli_data->hid_sensor_hubs[i], HID_INPUT_REPORT,
in_data->input_report[i], report_size, 0);
}
}
schedule_delayed_work(&cli_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP));
}

u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts)
static u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts)
{
if (mp2->mp2_ops->response)
sensor_sts = mp2->mp2_ops->response(mp2, sid, sensor_sts);

return sensor_sts;
}

const char *get_sensor_name(int idx)
static const char *get_sensor_name(int idx)
{
switch (idx) {
case accel_idx:
Expand All @@ -159,24 +155,82 @@ const char *get_sensor_name(int idx)
}
}

static void amd_sfh_resume(struct amd_mp2_dev *mp2)
{
struct amdtp_cl_data *cl_data = mp2->cl_data;
struct amd_mp2_sensor_info info;
int i, status;

for (i = 0; i < cl_data->num_hid_devices; i++) {
if (cl_data->sensor_sts[i] == SENSOR_DISABLED) {
info.period = AMD_SFH_IDLE_LOOP;
info.sensor_idx = cl_data->sensor_idx[i];
info.dma_address = cl_data->sensor_dma_addr[i];
mp2->mp2_ops->start(mp2, info);
status = amd_sfh_wait_for_response
(mp2, cl_data->sensor_idx[i], SENSOR_ENABLED);
if (status == SENSOR_ENABLED)
cl_data->sensor_sts[i] = SENSOR_ENABLED;
dev_dbg(&mp2->pdev->dev, "resume sid 0x%x (%s) status 0x%x\n",
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
cl_data->sensor_sts[i]);
}
}

schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP));
amd_sfh_clear_intr(mp2);
}

static void amd_sfh_suspend(struct amd_mp2_dev *mp2)
{
struct amdtp_cl_data *cl_data = mp2->cl_data;
int i, status;

for (i = 0; i < cl_data->num_hid_devices; i++) {
if (cl_data->sensor_idx[i] != HPD_IDX &&
cl_data->sensor_sts[i] == SENSOR_ENABLED) {
mp2->mp2_ops->stop(mp2, cl_data->sensor_idx[i]);
status = amd_sfh_wait_for_response
(mp2, cl_data->sensor_idx[i], SENSOR_DISABLED);
if (status != SENSOR_ENABLED)
cl_data->sensor_sts[i] = SENSOR_DISABLED;
dev_dbg(&mp2->pdev->dev, "suspend sid 0x%x (%s) status 0x%x\n",
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
cl_data->sensor_sts[i]);
}
}

cancel_delayed_work_sync(&cl_data->work_buffer);
amd_sfh_clear_intr(mp2);
}

int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
{
struct amd_input_data *in_data = &privdata->in_data;
struct amdtp_cl_data *cl_data = privdata->cl_data;
struct amd_mp2_ops *mp2_ops = privdata->mp2_ops;
struct amd_mp2_sensor_info info;
struct request_list *req_list;
struct device *dev;
u32 feature_report_size;
u32 input_report_size;
int rc, i, status;
u8 cl_idx;

req_list = &cl_data->req_list;
dev = &privdata->pdev->dev;
amd_sfh_set_desc_ops(mp2_ops);

mp2_ops->suspend = amd_sfh_suspend;
mp2_ops->resume = amd_sfh_resume;

cl_data->num_hid_devices = amd_mp2_get_sensor_num(privdata, &cl_data->sensor_idx[0]);
if (cl_data->num_hid_devices == 0)
return -ENODEV;

INIT_DELAYED_WORK(&cl_data->work, amd_sfh_work);
INIT_DELAYED_WORK(&cl_data->work_buffer, amd_sfh_work_buffer);
INIT_LIST_HEAD(&req_list.list);
INIT_LIST_HEAD(&req_list->list);
cl_data->in_data = in_data;

for (i = 0; i < cl_data->num_hid_devices; i++) {
Expand All @@ -187,17 +241,17 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
cl_data->sensor_requested_cnt[i] = 0;
cl_data->cur_hid_dev = i;
cl_idx = cl_data->sensor_idx[i];
cl_data->report_descr_sz[i] = get_descr_sz(cl_idx, descr_size);
cl_data->report_descr_sz[i] = mp2_ops->get_desc_sz(cl_idx, descr_size);
if (!cl_data->report_descr_sz[i]) {
rc = -EINVAL;
goto cleanup;
}
feature_report_size = get_descr_sz(cl_idx, feature_size);
feature_report_size = mp2_ops->get_desc_sz(cl_idx, feature_size);
if (!feature_report_size) {
rc = -EINVAL;
goto cleanup;
}
input_report_size = get_descr_sz(cl_idx, input_size);
input_report_size = mp2_ops->get_desc_sz(cl_idx, input_size);
if (!input_report_size) {
rc = -EINVAL;
goto cleanup;
Expand All @@ -222,17 +276,17 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
rc = -ENOMEM;
goto cleanup;
}
rc = get_report_descriptor(cl_idx, cl_data->report_descr[i]);
rc = mp2_ops->get_rep_desc(cl_idx, cl_data->report_descr[i]);
if (rc)
return rc;
privdata->mp2_ops->start(privdata, info);
mp2_ops->start(privdata, info);
status = amd_sfh_wait_for_response
(privdata, cl_data->sensor_idx[i], SENSOR_ENABLED);
if (status == SENSOR_ENABLED) {
cl_data->sensor_sts[i] = SENSOR_ENABLED;
rc = amdtp_hid_probe(cl_data->cur_hid_dev, cl_data);
if (rc) {
privdata->mp2_ops->stop(privdata, cl_data->sensor_idx[i]);
mp2_ops->stop(privdata, cl_data->sensor_idx[i]);
status = amd_sfh_wait_for_response
(privdata, cl_data->sensor_idx[i], SENSOR_DISABLED);
if (status != SENSOR_ENABLED)
Expand All @@ -248,8 +302,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
cl_data->sensor_sts[i]);
}
if (privdata->mp2_ops->discovery_status &&
privdata->mp2_ops->discovery_status(privdata) == 0) {
if (mp2_ops->discovery_status && mp2_ops->discovery_status(privdata) == 0) {
amd_sfh_hid_client_deinit(privdata);
for (i = 0; i < cl_data->num_hid_devices; i++) {
devm_kfree(dev, cl_data->feature_report[i]);
Expand Down
Loading

0 comments on commit 8d9420c

Please sign in to comment.