linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] HID: hid-goodix: Improve handling of HID feature reports
@ 2024-10-31 12:31 Charles Wang
  2024-10-31 12:31 ` [PATCH v2 1/2] HID: hid-goodix: Return 0 when receiving an empty HID feature package Charles Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Charles Wang @ 2024-10-31 12:31 UTC (permalink / raw)
  To: dmitry.torokhov, hbarnor
  Cc: jikos, bentiss, dianders, dan.carpenter, linux-input,
	linux-kernel, Charles Wang

The patchset introduces the following two changes:

1) Align with the i2c-hid driver by returning 0 instead of -EINVAL when
an empty response is received, ensuring that userspace programs utilizing
the hidraw node receive consistent return values.

2) Implement the hid get/set feature report function using a separate
address, rather than sharing an address with coordinate reporting, to
prevent feature events from being overwritten by coordinate events.

Signed-off-by: Charles Wang <charles.goodix@gmail.com>
---
Changes in v2:
- Split the commit into two patches.

---
Charles Wang (2):
  HID: hid-goodix: Return 0 when receiving an empty HID feature package
  HID: hid-goodix: Fix HID get/set feature operation overwritten problem

 drivers/hid/hid-goodix-spi.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] HID: hid-goodix: Return 0 when receiving an empty HID feature package
  2024-10-31 12:31 [PATCH v2 0/2] HID: hid-goodix: Improve handling of HID feature reports Charles Wang
@ 2024-10-31 12:31 ` Charles Wang
  2024-10-31 12:31 ` [PATCH v2 2/2] HID: hid-goodix: Fix HID get/set feature operation overwritten problem Charles Wang
  2024-11-06 14:09 ` [PATCH v2 0/2] HID: hid-goodix: Improve handling of HID feature reports Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: Charles Wang @ 2024-10-31 12:31 UTC (permalink / raw)
  To: dmitry.torokhov, hbarnor
  Cc: jikos, bentiss, dianders, dan.carpenter, linux-input,
	linux-kernel, Charles Wang

Align with the i2c-hid driver by returning 0 instead of -EINVAL when
an empty response is received, ensuring that userspace programs utilizing
the hidraw node receive consistent return values.

Signed-off-by: Charles Wang <charles.goodix@gmail.com>
---
 drivers/hid/hid-goodix-spi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-goodix-spi.c b/drivers/hid/hid-goodix-spi.c
index 0f87bf9c6..077a91ee1 100644
--- a/drivers/hid/hid-goodix-spi.c
+++ b/drivers/hid/hid-goodix-spi.c
@@ -356,7 +356,7 @@ static int goodix_hid_check_ack_status(struct goodix_ts_data *ts, u32 *resp_len)
 				dev_err(ts->dev, "hrd.size too short: %d", len);
 				return -EINVAL;
 			}
-			*resp_len = len;
+			*resp_len = len - GOODIX_HID_PKG_LEN_SIZE;
 			return 0;
 		}
 
@@ -446,7 +446,10 @@ static int goodix_hid_get_raw_report(struct hid_device *hid,
 	if (error)
 		return error;
 
-	len = min(len, response_data_len - GOODIX_HID_PKG_LEN_SIZE);
+	/* Empty reprot response */
+	if (!response_data_len)
+		return 0;
+	len = min(len, response_data_len);
 	/* Step3: read response data(skip 2bytes of hid pkg length) */
 	error = goodix_spi_read(ts, ts->hid_report_addr +
 				GOODIX_HID_ACK_HEADER_SIZE +
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] HID: hid-goodix: Fix HID get/set feature operation overwritten problem
  2024-10-31 12:31 [PATCH v2 0/2] HID: hid-goodix: Improve handling of HID feature reports Charles Wang
  2024-10-31 12:31 ` [PATCH v2 1/2] HID: hid-goodix: Return 0 when receiving an empty HID feature package Charles Wang
@ 2024-10-31 12:31 ` Charles Wang
  2024-11-06 14:09 ` [PATCH v2 0/2] HID: hid-goodix: Improve handling of HID feature reports Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: Charles Wang @ 2024-10-31 12:31 UTC (permalink / raw)
  To: dmitry.torokhov, hbarnor
  Cc: jikos, bentiss, dianders, dan.carpenter, linux-input,
	linux-kernel, Charles Wang

Implement the hid get/set feature report function using a separate
address, rather than sharing an address with coordinate reporting, to
prevent feature events from being overwritten by coordinate events.

Signed-off-by: Charles Wang <charles.goodix@gmail.com>
---
 drivers/hid/hid-goodix-spi.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/hid/hid-goodix-spi.c b/drivers/hid/hid-goodix-spi.c
index 077a91ee1..6ae2300a6 100644
--- a/drivers/hid/hid-goodix-spi.c
+++ b/drivers/hid/hid-goodix-spi.c
@@ -19,6 +19,7 @@
 #define GOODIX_HID_DESC_ADDR		0x1058C
 #define GOODIX_HID_REPORT_DESC_ADDR	0x105AA
 #define GOODIX_HID_SIGN_ADDR		0x10D32
+#define GOODIX_HID_CMD_ADDR		0x10364
 
 #define GOODIX_HID_GET_REPORT_CMD	0x02
 #define GOODIX_HID_SET_REPORT_CMD	0x03
@@ -348,7 +349,7 @@ static int goodix_hid_check_ack_status(struct goodix_ts_data *ts, u32 *resp_len)
 		 * - byte 0:    Ack flag, value of 1 for data ready
 		 * - bytes 1-2: Response data length
 		 */
-		error = goodix_spi_read(ts, ts->hid_report_addr,
+		error = goodix_spi_read(ts, GOODIX_HID_CMD_ADDR,
 					&hdr, sizeof(hdr));
 		if (!error && (hdr.flag & GOODIX_HID_ACK_READY_FLAG)) {
 			len = le16_to_cpu(hdr.size);
@@ -431,7 +432,7 @@ static int goodix_hid_get_raw_report(struct hid_device *hid,
 	tx_len += args_len;
 
 	/* Step1: write report request info */
-	error = goodix_spi_write(ts, ts->hid_report_addr, tmp_buf, tx_len);
+	error = goodix_spi_write(ts, GOODIX_HID_CMD_ADDR, tmp_buf, tx_len);
 	if (error) {
 		dev_err(ts->dev, "failed send read feature cmd, %d", error);
 		return error;
@@ -451,7 +452,7 @@ static int goodix_hid_get_raw_report(struct hid_device *hid,
 		return 0;
 	len = min(len, response_data_len);
 	/* Step3: read response data(skip 2bytes of hid pkg length) */
-	error = goodix_spi_read(ts, ts->hid_report_addr +
+	error = goodix_spi_read(ts, GOODIX_HID_CMD_ADDR +
 				GOODIX_HID_ACK_HEADER_SIZE +
 				GOODIX_HID_PKG_LEN_SIZE, buf, len);
 	if (error) {
@@ -521,7 +522,7 @@ static int goodix_hid_set_raw_report(struct hid_device *hid,
 	memcpy(tmp_buf + tx_len, buf, len);
 	tx_len += len;
 
-	error = goodix_spi_write(ts, ts->hid_report_addr, tmp_buf, tx_len);
+	error = goodix_spi_write(ts, GOODIX_HID_CMD_ADDR, tmp_buf, tx_len);
 	if (error) {
 		dev_err(ts->dev, "failed send report: %*ph", tx_len, tmp_buf);
 		return error;
@@ -752,7 +753,7 @@ static int goodix_spi_set_power(struct goodix_ts_data *ts, int power_state)
 	power_control_cmd[5] = power_state;
 
 	guard(mutex)(&ts->hid_request_lock);
-	error = goodix_spi_write(ts, ts->hid_report_addr, power_control_cmd,
+	error = goodix_spi_write(ts, GOODIX_HID_CMD_ADDR, power_control_cmd,
 				 sizeof(power_control_cmd));
 	if (error) {
 		dev_err(ts->dev, "failed set power mode: %s",
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] HID: hid-goodix: Improve handling of HID feature reports
  2024-10-31 12:31 [PATCH v2 0/2] HID: hid-goodix: Improve handling of HID feature reports Charles Wang
  2024-10-31 12:31 ` [PATCH v2 1/2] HID: hid-goodix: Return 0 when receiving an empty HID feature package Charles Wang
  2024-10-31 12:31 ` [PATCH v2 2/2] HID: hid-goodix: Fix HID get/set feature operation overwritten problem Charles Wang
@ 2024-11-06 14:09 ` Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2024-11-06 14:09 UTC (permalink / raw)
  To: Charles Wang
  Cc: dmitry.torokhov, hbarnor, bentiss, dianders, dan.carpenter,
	linux-input, linux-kernel

On Thu, 31 Oct 2024, Charles Wang wrote:

> The patchset introduces the following two changes:
> 
> 1) Align with the i2c-hid driver by returning 0 instead of -EINVAL when
> an empty response is received, ensuring that userspace programs utilizing
> the hidraw node receive consistent return values.
> 
> 2) Implement the hid get/set feature report function using a separate
> address, rather than sharing an address with coordinate reporting, to
> prevent feature events from being overwritten by coordinate events.
> 
> Signed-off-by: Charles Wang <charles.goodix@gmail.com>
> ---
> Changes in v2:
> - Split the commit into two patches.

Now queued in hid.git#for-6.13/goodix.

Thanks,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-06 14:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-31 12:31 [PATCH v2 0/2] HID: hid-goodix: Improve handling of HID feature reports Charles Wang
2024-10-31 12:31 ` [PATCH v2 1/2] HID: hid-goodix: Return 0 when receiving an empty HID feature package Charles Wang
2024-10-31 12:31 ` [PATCH v2 2/2] HID: hid-goodix: Fix HID get/set feature operation overwritten problem Charles Wang
2024-11-06 14:09 ` [PATCH v2 0/2] HID: hid-goodix: Improve handling of HID feature reports Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).