All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v13 1/3] HID: quirks: Allow inverting the absolute X/Y values
@ 2021-10-25 10:46 ` Alistair Francis
  0 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2021-10-25 10:46 UTC (permalink / raw)
  To: s.hauer, benjamin.tissoires, dmitry.torokhov, shawnguo
  Cc: alistair23, linux-kernel, linux-input, linux-imx,
	linux-arm-kernel, devicetree, jikos, Alistair Francis

Add a HID_QUIRK_X_INVERT/HID_QUIRK_Y_INVERT quirk that can be used
to invert the X/Y values.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
---
 drivers/hid/hid-input.c | 6 ++++++
 include/linux/hid.h     | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 4b5ebeacd283..4babf369184f 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1328,6 +1328,12 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
 
 	input = field->hidinput->input;
 
+	if (usage->type == EV_ABS &&
+		((*quirks & HID_QUIRK_X_INVERT) && usage->code == ABS_X ||
+		 (*quirks & HID_QUIRK_Y_INVERT) && usage->code == ABS_Y)) {
+			value = field->logical_maximum - value;
+	}
+
 	if (usage->hat_min < usage->hat_max || usage->hat_dir) {
 		int hat_dir = usage->hat_dir;
 		if (!hat_dir)
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 9e067f937dbc..4959385ca588 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -349,6 +349,8 @@ struct hid_item {
 /* BIT(9) reserved for backward compatibility, was NO_INIT_INPUT_REPORTS */
 #define HID_QUIRK_ALWAYS_POLL			BIT(10)
 #define HID_QUIRK_INPUT_PER_APP			BIT(11)
+#define HID_QUIRK_X_INVERT			BIT(12)
+#define HID_QUIRK_Y_INVERT			BIT(13)
 #define HID_QUIRK_SKIP_OUTPUT_REPORTS		BIT(16)
 #define HID_QUIRK_SKIP_OUTPUT_REPORT_ID		BIT(17)
 #define HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP	BIT(18)
-- 
2.31.1


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

* [PATCH v13 1/3] HID: quirks: Allow inverting the absolute X/Y values
@ 2021-10-25 10:46 ` Alistair Francis
  0 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2021-10-25 10:46 UTC (permalink / raw)
  To: s.hauer, benjamin.tissoires, dmitry.torokhov, shawnguo
  Cc: alistair23, linux-kernel, linux-input, linux-imx,
	linux-arm-kernel, devicetree, jikos, Alistair Francis

Add a HID_QUIRK_X_INVERT/HID_QUIRK_Y_INVERT quirk that can be used
to invert the X/Y values.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
---
 drivers/hid/hid-input.c | 6 ++++++
 include/linux/hid.h     | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 4b5ebeacd283..4babf369184f 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1328,6 +1328,12 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
 
 	input = field->hidinput->input;
 
+	if (usage->type == EV_ABS &&
+		((*quirks & HID_QUIRK_X_INVERT) && usage->code == ABS_X ||
+		 (*quirks & HID_QUIRK_Y_INVERT) && usage->code == ABS_Y)) {
+			value = field->logical_maximum - value;
+	}
+
 	if (usage->hat_min < usage->hat_max || usage->hat_dir) {
 		int hat_dir = usage->hat_dir;
 		if (!hat_dir)
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 9e067f937dbc..4959385ca588 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -349,6 +349,8 @@ struct hid_item {
 /* BIT(9) reserved for backward compatibility, was NO_INIT_INPUT_REPORTS */
 #define HID_QUIRK_ALWAYS_POLL			BIT(10)
 #define HID_QUIRK_INPUT_PER_APP			BIT(11)
+#define HID_QUIRK_X_INVERT			BIT(12)
+#define HID_QUIRK_Y_INVERT			BIT(13)
 #define HID_QUIRK_SKIP_OUTPUT_REPORTS		BIT(16)
 #define HID_QUIRK_SKIP_OUTPUT_REPORT_ID		BIT(17)
 #define HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP	BIT(18)
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v13 2/3] HID: i2c-hid-of: Expose the touchscreen-inverted properties
  2021-10-25 10:46 ` Alistair Francis
@ 2021-10-25 10:46   ` Alistair Francis
  -1 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2021-10-25 10:46 UTC (permalink / raw)
  To: s.hauer, benjamin.tissoires, dmitry.torokhov, shawnguo
  Cc: alistair23, linux-kernel, linux-input, linux-imx,
	linux-arm-kernel, devicetree, jikos, Alistair Francis

Allow the touchscreen-inverted-x/y device tree properties to control the
HID_QUIRK_X_INVERT/HID_QUIRK_Y_INVERT quirks for the hid-input device.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
---
 .../devicetree/bindings/input/hid-over-i2c.txt        |  2 ++
 drivers/hid/i2c-hid/i2c-hid-acpi.c                    |  2 +-
 drivers/hid/i2c-hid/i2c-hid-core.c                    |  4 +++-
 drivers/hid/i2c-hid/i2c-hid-of-goodix.c               |  2 +-
 drivers/hid/i2c-hid/i2c-hid-of.c                      | 11 ++++++++++-
 drivers/hid/i2c-hid/i2c-hid.h                         |  2 +-
 6 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/hid-over-i2c.txt b/Documentation/devicetree/bindings/input/hid-over-i2c.txt
index c76bafaf98d2..34c43d3bddfd 100644
--- a/Documentation/devicetree/bindings/input/hid-over-i2c.txt
+++ b/Documentation/devicetree/bindings/input/hid-over-i2c.txt
@@ -32,6 +32,8 @@ device-specific compatible properties, which should be used in addition to the
 - vdd-supply: phandle of the regulator that provides the supply voltage.
 - post-power-on-delay-ms: time required by the device after enabling its regulators
   or powering it on, before it is ready for communication.
+- touchscreen-inverted-x: See touchscreen.txt
+- touchscreen-inverted-y: See touchscreen.txt
 
 Example:
 
diff --git a/drivers/hid/i2c-hid/i2c-hid-acpi.c b/drivers/hid/i2c-hid/i2c-hid-acpi.c
index a6f0257a26de..b96ae15e0ad9 100644
--- a/drivers/hid/i2c-hid/i2c-hid-acpi.c
+++ b/drivers/hid/i2c-hid/i2c-hid-acpi.c
@@ -111,7 +111,7 @@ static int i2c_hid_acpi_probe(struct i2c_client *client)
 	}
 
 	return i2c_hid_core_probe(client, &ihid_acpi->ops,
-				  hid_descriptor_address);
+				  hid_descriptor_address, 0);
 }
 
 static const struct acpi_device_id i2c_hid_acpi_match[] = {
diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
index 517141138b00..4804d71e5293 100644
--- a/drivers/hid/i2c-hid/i2c-hid-core.c
+++ b/drivers/hid/i2c-hid/i2c-hid-core.c
@@ -912,7 +912,7 @@ static void i2c_hid_core_shutdown_tail(struct i2c_hid *ihid)
 }
 
 int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
-		       u16 hid_descriptor_address)
+		       u16 hid_descriptor_address, u32 quirks)
 {
 	int ret;
 	struct i2c_hid *ihid;
@@ -1009,6 +1009,8 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
 		goto err_mem_free;
 	}
 
+	hid->quirks |= quirks;
+
 	return 0;
 
 err_mem_free:
diff --git a/drivers/hid/i2c-hid/i2c-hid-of-goodix.c b/drivers/hid/i2c-hid/i2c-hid-of-goodix.c
index 52674149a275..b4dad66fa954 100644
--- a/drivers/hid/i2c-hid/i2c-hid-of-goodix.c
+++ b/drivers/hid/i2c-hid/i2c-hid-of-goodix.c
@@ -150,7 +150,7 @@ static int i2c_hid_of_goodix_probe(struct i2c_client *client,
 		goodix_i2c_hid_deassert_reset(ihid_goodix, true);
 	mutex_unlock(&ihid_goodix->regulator_mutex);
 
-	return i2c_hid_core_probe(client, &ihid_goodix->ops, 0x0001);
+	return i2c_hid_core_probe(client, &ihid_goodix->ops, 0x0001, 0);
 }
 
 static const struct goodix_i2c_hid_timing_data goodix_gt7375p_timing_data = {
diff --git a/drivers/hid/i2c-hid/i2c-hid-of.c b/drivers/hid/i2c-hid/i2c-hid-of.c
index 4bf7cea92637..b16349d6e9de 100644
--- a/drivers/hid/i2c-hid/i2c-hid-of.c
+++ b/drivers/hid/i2c-hid/i2c-hid-of.c
@@ -21,6 +21,7 @@
 
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/hid.h>
 #include <linux/i2c.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -71,6 +72,7 @@ static int i2c_hid_of_probe(struct i2c_client *client,
 	struct device *dev = &client->dev;
 	struct i2c_hid_of *ihid_of;
 	u16 hid_descriptor_address;
+	u32 quirks = 0;
 	int ret;
 	u32 val;
 
@@ -105,8 +107,15 @@ static int i2c_hid_of_probe(struct i2c_client *client,
 	if (ret)
 		return ret;
 
+	if (device_property_read_bool(dev, "touchscreen-inverted-x")) {
+		quirks |= HID_QUIRK_X_INVERT;
+	}
+	if (device_property_read_bool(dev, "touchscreen-inverted-y")) {
+		quirks |= HID_QUIRK_Y_INVERT;
+	}
+
 	return i2c_hid_core_probe(client, &ihid_of->ops,
-				  hid_descriptor_address);
+				  hid_descriptor_address, quirks);
 }
 
 static const struct of_device_id i2c_hid_of_match[] = {
diff --git a/drivers/hid/i2c-hid/i2c-hid.h b/drivers/hid/i2c-hid/i2c-hid.h
index 05a7827d211a..236cc062d5ef 100644
--- a/drivers/hid/i2c-hid/i2c-hid.h
+++ b/drivers/hid/i2c-hid/i2c-hid.h
@@ -32,7 +32,7 @@ struct i2chid_ops {
 };
 
 int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
-		       u16 hid_descriptor_address);
+		       u16 hid_descriptor_address, u32 quirks);
 int i2c_hid_core_remove(struct i2c_client *client);
 
 void i2c_hid_core_shutdown(struct i2c_client *client);
-- 
2.31.1


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

* [PATCH v13 2/3] HID: i2c-hid-of: Expose the touchscreen-inverted properties
@ 2021-10-25 10:46   ` Alistair Francis
  0 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2021-10-25 10:46 UTC (permalink / raw)
  To: s.hauer, benjamin.tissoires, dmitry.torokhov, shawnguo
  Cc: alistair23, linux-kernel, linux-input, linux-imx,
	linux-arm-kernel, devicetree, jikos, Alistair Francis

Allow the touchscreen-inverted-x/y device tree properties to control the
HID_QUIRK_X_INVERT/HID_QUIRK_Y_INVERT quirks for the hid-input device.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
---
 .../devicetree/bindings/input/hid-over-i2c.txt        |  2 ++
 drivers/hid/i2c-hid/i2c-hid-acpi.c                    |  2 +-
 drivers/hid/i2c-hid/i2c-hid-core.c                    |  4 +++-
 drivers/hid/i2c-hid/i2c-hid-of-goodix.c               |  2 +-
 drivers/hid/i2c-hid/i2c-hid-of.c                      | 11 ++++++++++-
 drivers/hid/i2c-hid/i2c-hid.h                         |  2 +-
 6 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/hid-over-i2c.txt b/Documentation/devicetree/bindings/input/hid-over-i2c.txt
index c76bafaf98d2..34c43d3bddfd 100644
--- a/Documentation/devicetree/bindings/input/hid-over-i2c.txt
+++ b/Documentation/devicetree/bindings/input/hid-over-i2c.txt
@@ -32,6 +32,8 @@ device-specific compatible properties, which should be used in addition to the
 - vdd-supply: phandle of the regulator that provides the supply voltage.
 - post-power-on-delay-ms: time required by the device after enabling its regulators
   or powering it on, before it is ready for communication.
+- touchscreen-inverted-x: See touchscreen.txt
+- touchscreen-inverted-y: See touchscreen.txt
 
 Example:
 
diff --git a/drivers/hid/i2c-hid/i2c-hid-acpi.c b/drivers/hid/i2c-hid/i2c-hid-acpi.c
index a6f0257a26de..b96ae15e0ad9 100644
--- a/drivers/hid/i2c-hid/i2c-hid-acpi.c
+++ b/drivers/hid/i2c-hid/i2c-hid-acpi.c
@@ -111,7 +111,7 @@ static int i2c_hid_acpi_probe(struct i2c_client *client)
 	}
 
 	return i2c_hid_core_probe(client, &ihid_acpi->ops,
-				  hid_descriptor_address);
+				  hid_descriptor_address, 0);
 }
 
 static const struct acpi_device_id i2c_hid_acpi_match[] = {
diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
index 517141138b00..4804d71e5293 100644
--- a/drivers/hid/i2c-hid/i2c-hid-core.c
+++ b/drivers/hid/i2c-hid/i2c-hid-core.c
@@ -912,7 +912,7 @@ static void i2c_hid_core_shutdown_tail(struct i2c_hid *ihid)
 }
 
 int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
-		       u16 hid_descriptor_address)
+		       u16 hid_descriptor_address, u32 quirks)
 {
 	int ret;
 	struct i2c_hid *ihid;
@@ -1009,6 +1009,8 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
 		goto err_mem_free;
 	}
 
+	hid->quirks |= quirks;
+
 	return 0;
 
 err_mem_free:
diff --git a/drivers/hid/i2c-hid/i2c-hid-of-goodix.c b/drivers/hid/i2c-hid/i2c-hid-of-goodix.c
index 52674149a275..b4dad66fa954 100644
--- a/drivers/hid/i2c-hid/i2c-hid-of-goodix.c
+++ b/drivers/hid/i2c-hid/i2c-hid-of-goodix.c
@@ -150,7 +150,7 @@ static int i2c_hid_of_goodix_probe(struct i2c_client *client,
 		goodix_i2c_hid_deassert_reset(ihid_goodix, true);
 	mutex_unlock(&ihid_goodix->regulator_mutex);
 
-	return i2c_hid_core_probe(client, &ihid_goodix->ops, 0x0001);
+	return i2c_hid_core_probe(client, &ihid_goodix->ops, 0x0001, 0);
 }
 
 static const struct goodix_i2c_hid_timing_data goodix_gt7375p_timing_data = {
diff --git a/drivers/hid/i2c-hid/i2c-hid-of.c b/drivers/hid/i2c-hid/i2c-hid-of.c
index 4bf7cea92637..b16349d6e9de 100644
--- a/drivers/hid/i2c-hid/i2c-hid-of.c
+++ b/drivers/hid/i2c-hid/i2c-hid-of.c
@@ -21,6 +21,7 @@
 
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/hid.h>
 #include <linux/i2c.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -71,6 +72,7 @@ static int i2c_hid_of_probe(struct i2c_client *client,
 	struct device *dev = &client->dev;
 	struct i2c_hid_of *ihid_of;
 	u16 hid_descriptor_address;
+	u32 quirks = 0;
 	int ret;
 	u32 val;
 
@@ -105,8 +107,15 @@ static int i2c_hid_of_probe(struct i2c_client *client,
 	if (ret)
 		return ret;
 
+	if (device_property_read_bool(dev, "touchscreen-inverted-x")) {
+		quirks |= HID_QUIRK_X_INVERT;
+	}
+	if (device_property_read_bool(dev, "touchscreen-inverted-y")) {
+		quirks |= HID_QUIRK_Y_INVERT;
+	}
+
 	return i2c_hid_core_probe(client, &ihid_of->ops,
-				  hid_descriptor_address);
+				  hid_descriptor_address, quirks);
 }
 
 static const struct of_device_id i2c_hid_of_match[] = {
diff --git a/drivers/hid/i2c-hid/i2c-hid.h b/drivers/hid/i2c-hid/i2c-hid.h
index 05a7827d211a..236cc062d5ef 100644
--- a/drivers/hid/i2c-hid/i2c-hid.h
+++ b/drivers/hid/i2c-hid/i2c-hid.h
@@ -32,7 +32,7 @@ struct i2chid_ops {
 };
 
 int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
-		       u16 hid_descriptor_address);
+		       u16 hid_descriptor_address, u32 quirks);
 int i2c_hid_core_remove(struct i2c_client *client);
 
 void i2c_hid_core_shutdown(struct i2c_client *client);
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v13 3/3] ARM: dts: imx7d: remarkable2: add wacom digitizer device
  2021-10-25 10:46 ` Alistair Francis
@ 2021-10-25 10:46   ` Alistair Francis
  -1 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2021-10-25 10:46 UTC (permalink / raw)
  To: s.hauer, benjamin.tissoires, dmitry.torokhov, shawnguo
  Cc: alistair23, linux-kernel, linux-input, linux-imx,
	linux-arm-kernel, devicetree, jikos, Alistair Francis

Signed-off-by: Alistair Francis <alistair@alistair23.me>
---
 arch/arm/boot/dts/imx7d-remarkable2.dts | 59 +++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts b/arch/arm/boot/dts/imx7d-remarkable2.dts
index 89cbf13097a4..a2a91bfdd98e 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -34,6 +34,19 @@ reg_brcm: regulator-brcm {
 		startup-delay-us = <150>;
 	};
 
+	reg_digitizer: regulator-digitizer {
+		compatible = "regulator-fixed";
+		regulator-name = "VDD_3V3_DIGITIZER";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		pinctrl-names = "default", "sleep";
+		pinctrl-0 = <&pinctrl_digitizer_reg>;
+		pinctrl-1 = <&pinctrl_digitizer_reg>;
+		gpio = <&gpio1 6 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+		startup-delay-us = <100000>; /* 100 ms */
+	};
+
 	wifi_pwrseq: wifi_pwrseq {
 		compatible = "mmc-pwrseq-simple";
 		pinctrl-names = "default";
@@ -51,6 +64,26 @@ &clks {
 	assigned-clock-rates = <0>, <32768>;
 };
 
+&i2c1 {
+	clock-frequency = <400000>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_i2c1>;
+	status = "okay";
+
+	wacom_digitizer: digitizer@9 {
+		compatible = "hid-over-i2c";
+		reg = <0x09>;
+		hid-descr-addr = <0x01>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_wacom>;
+		interrupt-parent = <&gpio1>;
+		interrupts = <1 IRQ_TYPE_LEVEL_LOW>;
+		touchscreen-inverted-x;
+		touchscreen-inverted-y;
+		vdd-supply = <&reg_digitizer>;
+	};
+};
+
 &snvs_pwrkey {
 	status = "okay";
 };
@@ -117,6 +150,25 @@ &wdog1 {
 	fsl,ext-reset-output;
 };
 
+&iomuxc_lpsr {
+	pinctrl_digitizer_reg: digitizerreggrp {
+		fsl,pins = <
+			/* DIGITIZER_PWR_EN */
+			MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6	0x14
+		>;
+	};
+
+	pinctrl_wacom: wacomgrp {
+		fsl,pins = <
+			/*MX7D_PAD_LPSR_GPIO1_IO05__GPIO1_IO5	0x00000014 FWE */
+			MX7D_PAD_LPSR_GPIO1_IO04__GPIO1_IO4	0x00000074 /* PDCTB */
+			MX7D_PAD_LPSR_GPIO1_IO01__GPIO1_IO1	0x00000034 /* WACOM INT */
+			/*MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6	0x00000014 WACOM PWR ENABLE */
+			/*MX7D_PAD_LPSR_GPIO1_IO00__GPIO1_IO0	0x00000074 WACOM RESET */
+		>;
+	};
+};
+
 &iomuxc {
 	pinctrl_brcm_reg: brcmreggrp {
 		fsl,pins = <
@@ -125,6 +177,13 @@ MX7D_PAD_SAI1_TX_BCLK__GPIO6_IO13	0x14
 		>;
 	};
 
+	pinctrl_i2c1: i2c1grp {
+		fsl,pins = <
+			MX7D_PAD_I2C1_SDA__I2C1_SDA		0x4000007f
+			MX7D_PAD_I2C1_SCL__I2C1_SCL		0x4000007f
+		>;
+	};
+
 	pinctrl_uart1: uart1grp {
 		fsl,pins = <
 			MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX	0x79
-- 
2.31.1


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

* [PATCH v13 3/3] ARM: dts: imx7d: remarkable2: add wacom digitizer device
@ 2021-10-25 10:46   ` Alistair Francis
  0 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2021-10-25 10:46 UTC (permalink / raw)
  To: s.hauer, benjamin.tissoires, dmitry.torokhov, shawnguo
  Cc: alistair23, linux-kernel, linux-input, linux-imx,
	linux-arm-kernel, devicetree, jikos, Alistair Francis

Signed-off-by: Alistair Francis <alistair@alistair23.me>
---
 arch/arm/boot/dts/imx7d-remarkable2.dts | 59 +++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts b/arch/arm/boot/dts/imx7d-remarkable2.dts
index 89cbf13097a4..a2a91bfdd98e 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -34,6 +34,19 @@ reg_brcm: regulator-brcm {
 		startup-delay-us = <150>;
 	};
 
+	reg_digitizer: regulator-digitizer {
+		compatible = "regulator-fixed";
+		regulator-name = "VDD_3V3_DIGITIZER";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		pinctrl-names = "default", "sleep";
+		pinctrl-0 = <&pinctrl_digitizer_reg>;
+		pinctrl-1 = <&pinctrl_digitizer_reg>;
+		gpio = <&gpio1 6 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+		startup-delay-us = <100000>; /* 100 ms */
+	};
+
 	wifi_pwrseq: wifi_pwrseq {
 		compatible = "mmc-pwrseq-simple";
 		pinctrl-names = "default";
@@ -51,6 +64,26 @@ &clks {
 	assigned-clock-rates = <0>, <32768>;
 };
 
+&i2c1 {
+	clock-frequency = <400000>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_i2c1>;
+	status = "okay";
+
+	wacom_digitizer: digitizer@9 {
+		compatible = "hid-over-i2c";
+		reg = <0x09>;
+		hid-descr-addr = <0x01>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_wacom>;
+		interrupt-parent = <&gpio1>;
+		interrupts = <1 IRQ_TYPE_LEVEL_LOW>;
+		touchscreen-inverted-x;
+		touchscreen-inverted-y;
+		vdd-supply = <&reg_digitizer>;
+	};
+};
+
 &snvs_pwrkey {
 	status = "okay";
 };
@@ -117,6 +150,25 @@ &wdog1 {
 	fsl,ext-reset-output;
 };
 
+&iomuxc_lpsr {
+	pinctrl_digitizer_reg: digitizerreggrp {
+		fsl,pins = <
+			/* DIGITIZER_PWR_EN */
+			MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6	0x14
+		>;
+	};
+
+	pinctrl_wacom: wacomgrp {
+		fsl,pins = <
+			/*MX7D_PAD_LPSR_GPIO1_IO05__GPIO1_IO5	0x00000014 FWE */
+			MX7D_PAD_LPSR_GPIO1_IO04__GPIO1_IO4	0x00000074 /* PDCTB */
+			MX7D_PAD_LPSR_GPIO1_IO01__GPIO1_IO1	0x00000034 /* WACOM INT */
+			/*MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6	0x00000014 WACOM PWR ENABLE */
+			/*MX7D_PAD_LPSR_GPIO1_IO00__GPIO1_IO0	0x00000074 WACOM RESET */
+		>;
+	};
+};
+
 &iomuxc {
 	pinctrl_brcm_reg: brcmreggrp {
 		fsl,pins = <
@@ -125,6 +177,13 @@ MX7D_PAD_SAI1_TX_BCLK__GPIO6_IO13	0x14
 		>;
 	};
 
+	pinctrl_i2c1: i2c1grp {
+		fsl,pins = <
+			MX7D_PAD_I2C1_SDA__I2C1_SDA		0x4000007f
+			MX7D_PAD_I2C1_SCL__I2C1_SCL		0x4000007f
+		>;
+	};
+
 	pinctrl_uart1: uart1grp {
 		fsl,pins = <
 			MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX	0x79
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v13 1/3] HID: quirks: Allow inverting the absolute X/Y values
  2021-10-25 10:46 ` Alistair Francis
  (?)
@ 2021-10-26 13:30   ` kernel test robot
  -1 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-10-26 13:30 UTC (permalink / raw)
  To: Alistair Francis, s.hauer, benjamin.tissoires, dmitry.torokhov, shawnguo
  Cc: kbuild-all, alistair23, linux-kernel, linux-input, linux-imx,
	linux-arm-kernel, devicetree

[-- Attachment #1: Type: text/plain, Size: 7570 bytes --]

Hi Alistair,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on hid/for-next]
[also build test WARNING on dtor-input/next robh/for-next v5.15-rc7 next-20211026]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Alistair-Francis/HID-quirks-Allow-inverting-the-absolute-X-Y-values/20211025-184729
base:   https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
config: ia64-defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/ccc9b072f0233da9c215622b32ed61852df33627
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Alistair-Francis/HID-quirks-Allow-inverting-the-absolute-X-Y-values/20211025-184729
        git checkout ccc9b072f0233da9c215622b32ed61852df33627
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/hid/hid-input.c: In function 'hidinput_hid_event':
>> drivers/hid/hid-input.c:1333:49: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
    1333 |                 ((*quirks & HID_QUIRK_X_INVERT) && usage->code == ABS_X ||


vim +1333 drivers/hid/hid-input.c

  1313	
  1314	void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
  1315	{
  1316		struct input_dev *input;
  1317		unsigned *quirks = &hid->quirks;
  1318	
  1319		if (!usage->type)
  1320			return;
  1321	
  1322		if (usage->type == EV_PWR) {
  1323			hidinput_update_battery(hid, value);
  1324			return;
  1325		}
  1326	
  1327		if (!field->hidinput)
  1328			return;
  1329	
  1330		input = field->hidinput->input;
  1331	
  1332		if (usage->type == EV_ABS &&
> 1333			((*quirks & HID_QUIRK_X_INVERT) && usage->code == ABS_X ||
  1334			 (*quirks & HID_QUIRK_Y_INVERT) && usage->code == ABS_Y)) {
  1335				value = field->logical_maximum - value;
  1336		}
  1337	
  1338		if (usage->hat_min < usage->hat_max || usage->hat_dir) {
  1339			int hat_dir = usage->hat_dir;
  1340			if (!hat_dir)
  1341				hat_dir = (value - usage->hat_min) * 8 / (usage->hat_max - usage->hat_min + 1) + 1;
  1342			if (hat_dir < 0 || hat_dir > 8) hat_dir = 0;
  1343			input_event(input, usage->type, usage->code    , hid_hat_to_axis[hat_dir].x);
  1344			input_event(input, usage->type, usage->code + 1, hid_hat_to_axis[hat_dir].y);
  1345			return;
  1346		}
  1347	
  1348		if (usage->hid == HID_DG_INVERT) {
  1349			*quirks = value ? (*quirks | HID_QUIRK_INVERT) : (*quirks & ~HID_QUIRK_INVERT);
  1350			return;
  1351		}
  1352	
  1353		if (usage->hid == HID_DG_INRANGE) {
  1354			if (value) {
  1355				input_event(input, usage->type, (*quirks & HID_QUIRK_INVERT) ? BTN_TOOL_RUBBER : usage->code, 1);
  1356				return;
  1357			}
  1358			input_event(input, usage->type, usage->code, 0);
  1359			input_event(input, usage->type, BTN_TOOL_RUBBER, 0);
  1360			return;
  1361		}
  1362	
  1363		if (usage->hid == HID_DG_TIPPRESSURE && (*quirks & HID_QUIRK_NOTOUCH)) {
  1364			int a = field->logical_minimum;
  1365			int b = field->logical_maximum;
  1366			input_event(input, EV_KEY, BTN_TOUCH, value > a + ((b - a) >> 3));
  1367		}
  1368	
  1369		if (usage->hid == (HID_UP_PID | 0x83UL)) { /* Simultaneous Effects Max */
  1370			dbg_hid("Maximum Effects - %d\n",value);
  1371			return;
  1372		}
  1373	
  1374		if (usage->hid == (HID_UP_PID | 0x7fUL)) {
  1375			dbg_hid("PID Pool Report\n");
  1376			return;
  1377		}
  1378	
  1379		if ((usage->type == EV_KEY) && (usage->code == 0)) /* Key 0 is "unassigned", not KEY_UNKNOWN */
  1380			return;
  1381	
  1382		if ((usage->type == EV_REL) && (usage->code == REL_WHEEL_HI_RES ||
  1383						usage->code == REL_HWHEEL_HI_RES)) {
  1384			hidinput_handle_scroll(usage, input, value);
  1385			return;
  1386		}
  1387	
  1388		if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) &&
  1389				(usage->code == ABS_VOLUME)) {
  1390			int count = abs(value);
  1391			int direction = value > 0 ? KEY_VOLUMEUP : KEY_VOLUMEDOWN;
  1392			int i;
  1393	
  1394			for (i = 0; i < count; i++) {
  1395				input_event(input, EV_KEY, direction, 1);
  1396				input_sync(input);
  1397				input_event(input, EV_KEY, direction, 0);
  1398				input_sync(input);
  1399			}
  1400			return;
  1401		}
  1402	
  1403		/*
  1404		 * Ignore out-of-range values as per HID specification,
  1405		 * section 5.10 and 6.2.25, when NULL state bit is present.
  1406		 * When it's not, clamp the value to match Microsoft's input
  1407		 * driver as mentioned in "Required HID usages for digitizers":
  1408		 * https://msdn.microsoft.com/en-us/library/windows/hardware/dn672278(v=vs.85).asp
  1409		 *
  1410		 * The logical_minimum < logical_maximum check is done so that we
  1411		 * don't unintentionally discard values sent by devices which
  1412		 * don't specify logical min and max.
  1413		 */
  1414		if ((field->flags & HID_MAIN_ITEM_VARIABLE) &&
  1415		    (field->logical_minimum < field->logical_maximum)) {
  1416			if (field->flags & HID_MAIN_ITEM_NULL_STATE &&
  1417			    (value < field->logical_minimum ||
  1418			     value > field->logical_maximum)) {
  1419				dbg_hid("Ignoring out-of-range value %x\n", value);
  1420				return;
  1421			}
  1422			value = clamp(value,
  1423				      field->logical_minimum,
  1424				      field->logical_maximum);
  1425		}
  1426	
  1427		/*
  1428		 * Ignore reports for absolute data if the data didn't change. This is
  1429		 * not only an optimization but also fixes 'dead' key reports. Some
  1430		 * RollOver implementations for localized keys (like BACKSLASH/PIPE; HID
  1431		 * 0x31 and 0x32) report multiple keys, even though a localized keyboard
  1432		 * can only have one of them physically available. The 'dead' keys
  1433		 * report constant 0. As all map to the same keycode, they'd confuse
  1434		 * the input layer. If we filter the 'dead' keys on the HID level, we
  1435		 * skip the keycode translation and only forward real events.
  1436		 */
  1437		if (!(field->flags & (HID_MAIN_ITEM_RELATIVE |
  1438		                      HID_MAIN_ITEM_BUFFERED_BYTE)) &&
  1439				      (field->flags & HID_MAIN_ITEM_VARIABLE) &&
  1440		    usage->usage_index < field->maxusage &&
  1441		    value == field->value[usage->usage_index])
  1442			return;
  1443	
  1444		/* report the usage code as scancode if the key status has changed */
  1445		if (usage->type == EV_KEY &&
  1446		    (!test_bit(usage->code, input->key)) == value)
  1447			input_event(input, EV_MSC, MSC_SCAN, usage->hid);
  1448	
  1449		input_event(input, usage->type, usage->code, value);
  1450	
  1451		if ((field->flags & HID_MAIN_ITEM_RELATIVE) &&
  1452		    usage->type == EV_KEY && value) {
  1453			input_sync(input);
  1454			input_event(input, usage->type, usage->code, 0);
  1455		}
  1456	}
  1457	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 19980 bytes --]

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

* Re: [PATCH v13 1/3] HID: quirks: Allow inverting the absolute X/Y values
@ 2021-10-26 13:30   ` kernel test robot
  0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-10-26 13:30 UTC (permalink / raw)
  To: Alistair Francis, s.hauer, benjamin.tissoires, dmitry.torokhov, shawnguo
  Cc: kbuild-all, alistair23, linux-kernel, linux-input, linux-imx,
	linux-arm-kernel, devicetree

[-- Attachment #1: Type: text/plain, Size: 7570 bytes --]

Hi Alistair,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on hid/for-next]
[also build test WARNING on dtor-input/next robh/for-next v5.15-rc7 next-20211026]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Alistair-Francis/HID-quirks-Allow-inverting-the-absolute-X-Y-values/20211025-184729
base:   https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
config: ia64-defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/ccc9b072f0233da9c215622b32ed61852df33627
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Alistair-Francis/HID-quirks-Allow-inverting-the-absolute-X-Y-values/20211025-184729
        git checkout ccc9b072f0233da9c215622b32ed61852df33627
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/hid/hid-input.c: In function 'hidinput_hid_event':
>> drivers/hid/hid-input.c:1333:49: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
    1333 |                 ((*quirks & HID_QUIRK_X_INVERT) && usage->code == ABS_X ||


vim +1333 drivers/hid/hid-input.c

  1313	
  1314	void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
  1315	{
  1316		struct input_dev *input;
  1317		unsigned *quirks = &hid->quirks;
  1318	
  1319		if (!usage->type)
  1320			return;
  1321	
  1322		if (usage->type == EV_PWR) {
  1323			hidinput_update_battery(hid, value);
  1324			return;
  1325		}
  1326	
  1327		if (!field->hidinput)
  1328			return;
  1329	
  1330		input = field->hidinput->input;
  1331	
  1332		if (usage->type == EV_ABS &&
> 1333			((*quirks & HID_QUIRK_X_INVERT) && usage->code == ABS_X ||
  1334			 (*quirks & HID_QUIRK_Y_INVERT) && usage->code == ABS_Y)) {
  1335				value = field->logical_maximum - value;
  1336		}
  1337	
  1338		if (usage->hat_min < usage->hat_max || usage->hat_dir) {
  1339			int hat_dir = usage->hat_dir;
  1340			if (!hat_dir)
  1341				hat_dir = (value - usage->hat_min) * 8 / (usage->hat_max - usage->hat_min + 1) + 1;
  1342			if (hat_dir < 0 || hat_dir > 8) hat_dir = 0;
  1343			input_event(input, usage->type, usage->code    , hid_hat_to_axis[hat_dir].x);
  1344			input_event(input, usage->type, usage->code + 1, hid_hat_to_axis[hat_dir].y);
  1345			return;
  1346		}
  1347	
  1348		if (usage->hid == HID_DG_INVERT) {
  1349			*quirks = value ? (*quirks | HID_QUIRK_INVERT) : (*quirks & ~HID_QUIRK_INVERT);
  1350			return;
  1351		}
  1352	
  1353		if (usage->hid == HID_DG_INRANGE) {
  1354			if (value) {
  1355				input_event(input, usage->type, (*quirks & HID_QUIRK_INVERT) ? BTN_TOOL_RUBBER : usage->code, 1);
  1356				return;
  1357			}
  1358			input_event(input, usage->type, usage->code, 0);
  1359			input_event(input, usage->type, BTN_TOOL_RUBBER, 0);
  1360			return;
  1361		}
  1362	
  1363		if (usage->hid == HID_DG_TIPPRESSURE && (*quirks & HID_QUIRK_NOTOUCH)) {
  1364			int a = field->logical_minimum;
  1365			int b = field->logical_maximum;
  1366			input_event(input, EV_KEY, BTN_TOUCH, value > a + ((b - a) >> 3));
  1367		}
  1368	
  1369		if (usage->hid == (HID_UP_PID | 0x83UL)) { /* Simultaneous Effects Max */
  1370			dbg_hid("Maximum Effects - %d\n",value);
  1371			return;
  1372		}
  1373	
  1374		if (usage->hid == (HID_UP_PID | 0x7fUL)) {
  1375			dbg_hid("PID Pool Report\n");
  1376			return;
  1377		}
  1378	
  1379		if ((usage->type == EV_KEY) && (usage->code == 0)) /* Key 0 is "unassigned", not KEY_UNKNOWN */
  1380			return;
  1381	
  1382		if ((usage->type == EV_REL) && (usage->code == REL_WHEEL_HI_RES ||
  1383						usage->code == REL_HWHEEL_HI_RES)) {
  1384			hidinput_handle_scroll(usage, input, value);
  1385			return;
  1386		}
  1387	
  1388		if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) &&
  1389				(usage->code == ABS_VOLUME)) {
  1390			int count = abs(value);
  1391			int direction = value > 0 ? KEY_VOLUMEUP : KEY_VOLUMEDOWN;
  1392			int i;
  1393	
  1394			for (i = 0; i < count; i++) {
  1395				input_event(input, EV_KEY, direction, 1);
  1396				input_sync(input);
  1397				input_event(input, EV_KEY, direction, 0);
  1398				input_sync(input);
  1399			}
  1400			return;
  1401		}
  1402	
  1403		/*
  1404		 * Ignore out-of-range values as per HID specification,
  1405		 * section 5.10 and 6.2.25, when NULL state bit is present.
  1406		 * When it's not, clamp the value to match Microsoft's input
  1407		 * driver as mentioned in "Required HID usages for digitizers":
  1408		 * https://msdn.microsoft.com/en-us/library/windows/hardware/dn672278(v=vs.85).asp
  1409		 *
  1410		 * The logical_minimum < logical_maximum check is done so that we
  1411		 * don't unintentionally discard values sent by devices which
  1412		 * don't specify logical min and max.
  1413		 */
  1414		if ((field->flags & HID_MAIN_ITEM_VARIABLE) &&
  1415		    (field->logical_minimum < field->logical_maximum)) {
  1416			if (field->flags & HID_MAIN_ITEM_NULL_STATE &&
  1417			    (value < field->logical_minimum ||
  1418			     value > field->logical_maximum)) {
  1419				dbg_hid("Ignoring out-of-range value %x\n", value);
  1420				return;
  1421			}
  1422			value = clamp(value,
  1423				      field->logical_minimum,
  1424				      field->logical_maximum);
  1425		}
  1426	
  1427		/*
  1428		 * Ignore reports for absolute data if the data didn't change. This is
  1429		 * not only an optimization but also fixes 'dead' key reports. Some
  1430		 * RollOver implementations for localized keys (like BACKSLASH/PIPE; HID
  1431		 * 0x31 and 0x32) report multiple keys, even though a localized keyboard
  1432		 * can only have one of them physically available. The 'dead' keys
  1433		 * report constant 0. As all map to the same keycode, they'd confuse
  1434		 * the input layer. If we filter the 'dead' keys on the HID level, we
  1435		 * skip the keycode translation and only forward real events.
  1436		 */
  1437		if (!(field->flags & (HID_MAIN_ITEM_RELATIVE |
  1438		                      HID_MAIN_ITEM_BUFFERED_BYTE)) &&
  1439				      (field->flags & HID_MAIN_ITEM_VARIABLE) &&
  1440		    usage->usage_index < field->maxusage &&
  1441		    value == field->value[usage->usage_index])
  1442			return;
  1443	
  1444		/* report the usage code as scancode if the key status has changed */
  1445		if (usage->type == EV_KEY &&
  1446		    (!test_bit(usage->code, input->key)) == value)
  1447			input_event(input, EV_MSC, MSC_SCAN, usage->hid);
  1448	
  1449		input_event(input, usage->type, usage->code, value);
  1450	
  1451		if ((field->flags & HID_MAIN_ITEM_RELATIVE) &&
  1452		    usage->type == EV_KEY && value) {
  1453			input_sync(input);
  1454			input_event(input, usage->type, usage->code, 0);
  1455		}
  1456	}
  1457	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 19980 bytes --]

[-- Attachment #3: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v13 1/3] HID: quirks: Allow inverting the absolute X/Y values
@ 2021-10-26 13:30   ` kernel test robot
  0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-10-26 13:30 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 7757 bytes --]

Hi Alistair,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on hid/for-next]
[also build test WARNING on dtor-input/next robh/for-next v5.15-rc7 next-20211026]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Alistair-Francis/HID-quirks-Allow-inverting-the-absolute-X-Y-values/20211025-184729
base:   https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
config: ia64-defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/ccc9b072f0233da9c215622b32ed61852df33627
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Alistair-Francis/HID-quirks-Allow-inverting-the-absolute-X-Y-values/20211025-184729
        git checkout ccc9b072f0233da9c215622b32ed61852df33627
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/hid/hid-input.c: In function 'hidinput_hid_event':
>> drivers/hid/hid-input.c:1333:49: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
    1333 |                 ((*quirks & HID_QUIRK_X_INVERT) && usage->code == ABS_X ||


vim +1333 drivers/hid/hid-input.c

  1313	
  1314	void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
  1315	{
  1316		struct input_dev *input;
  1317		unsigned *quirks = &hid->quirks;
  1318	
  1319		if (!usage->type)
  1320			return;
  1321	
  1322		if (usage->type == EV_PWR) {
  1323			hidinput_update_battery(hid, value);
  1324			return;
  1325		}
  1326	
  1327		if (!field->hidinput)
  1328			return;
  1329	
  1330		input = field->hidinput->input;
  1331	
  1332		if (usage->type == EV_ABS &&
> 1333			((*quirks & HID_QUIRK_X_INVERT) && usage->code == ABS_X ||
  1334			 (*quirks & HID_QUIRK_Y_INVERT) && usage->code == ABS_Y)) {
  1335				value = field->logical_maximum - value;
  1336		}
  1337	
  1338		if (usage->hat_min < usage->hat_max || usage->hat_dir) {
  1339			int hat_dir = usage->hat_dir;
  1340			if (!hat_dir)
  1341				hat_dir = (value - usage->hat_min) * 8 / (usage->hat_max - usage->hat_min + 1) + 1;
  1342			if (hat_dir < 0 || hat_dir > 8) hat_dir = 0;
  1343			input_event(input, usage->type, usage->code    , hid_hat_to_axis[hat_dir].x);
  1344			input_event(input, usage->type, usage->code + 1, hid_hat_to_axis[hat_dir].y);
  1345			return;
  1346		}
  1347	
  1348		if (usage->hid == HID_DG_INVERT) {
  1349			*quirks = value ? (*quirks | HID_QUIRK_INVERT) : (*quirks & ~HID_QUIRK_INVERT);
  1350			return;
  1351		}
  1352	
  1353		if (usage->hid == HID_DG_INRANGE) {
  1354			if (value) {
  1355				input_event(input, usage->type, (*quirks & HID_QUIRK_INVERT) ? BTN_TOOL_RUBBER : usage->code, 1);
  1356				return;
  1357			}
  1358			input_event(input, usage->type, usage->code, 0);
  1359			input_event(input, usage->type, BTN_TOOL_RUBBER, 0);
  1360			return;
  1361		}
  1362	
  1363		if (usage->hid == HID_DG_TIPPRESSURE && (*quirks & HID_QUIRK_NOTOUCH)) {
  1364			int a = field->logical_minimum;
  1365			int b = field->logical_maximum;
  1366			input_event(input, EV_KEY, BTN_TOUCH, value > a + ((b - a) >> 3));
  1367		}
  1368	
  1369		if (usage->hid == (HID_UP_PID | 0x83UL)) { /* Simultaneous Effects Max */
  1370			dbg_hid("Maximum Effects - %d\n",value);
  1371			return;
  1372		}
  1373	
  1374		if (usage->hid == (HID_UP_PID | 0x7fUL)) {
  1375			dbg_hid("PID Pool Report\n");
  1376			return;
  1377		}
  1378	
  1379		if ((usage->type == EV_KEY) && (usage->code == 0)) /* Key 0 is "unassigned", not KEY_UNKNOWN */
  1380			return;
  1381	
  1382		if ((usage->type == EV_REL) && (usage->code == REL_WHEEL_HI_RES ||
  1383						usage->code == REL_HWHEEL_HI_RES)) {
  1384			hidinput_handle_scroll(usage, input, value);
  1385			return;
  1386		}
  1387	
  1388		if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) &&
  1389				(usage->code == ABS_VOLUME)) {
  1390			int count = abs(value);
  1391			int direction = value > 0 ? KEY_VOLUMEUP : KEY_VOLUMEDOWN;
  1392			int i;
  1393	
  1394			for (i = 0; i < count; i++) {
  1395				input_event(input, EV_KEY, direction, 1);
  1396				input_sync(input);
  1397				input_event(input, EV_KEY, direction, 0);
  1398				input_sync(input);
  1399			}
  1400			return;
  1401		}
  1402	
  1403		/*
  1404		 * Ignore out-of-range values as per HID specification,
  1405		 * section 5.10 and 6.2.25, when NULL state bit is present.
  1406		 * When it's not, clamp the value to match Microsoft's input
  1407		 * driver as mentioned in "Required HID usages for digitizers":
  1408		 * https://msdn.microsoft.com/en-us/library/windows/hardware/dn672278(v=vs.85).asp
  1409		 *
  1410		 * The logical_minimum < logical_maximum check is done so that we
  1411		 * don't unintentionally discard values sent by devices which
  1412		 * don't specify logical min and max.
  1413		 */
  1414		if ((field->flags & HID_MAIN_ITEM_VARIABLE) &&
  1415		    (field->logical_minimum < field->logical_maximum)) {
  1416			if (field->flags & HID_MAIN_ITEM_NULL_STATE &&
  1417			    (value < field->logical_minimum ||
  1418			     value > field->logical_maximum)) {
  1419				dbg_hid("Ignoring out-of-range value %x\n", value);
  1420				return;
  1421			}
  1422			value = clamp(value,
  1423				      field->logical_minimum,
  1424				      field->logical_maximum);
  1425		}
  1426	
  1427		/*
  1428		 * Ignore reports for absolute data if the data didn't change. This is
  1429		 * not only an optimization but also fixes 'dead' key reports. Some
  1430		 * RollOver implementations for localized keys (like BACKSLASH/PIPE; HID
  1431		 * 0x31 and 0x32) report multiple keys, even though a localized keyboard
  1432		 * can only have one of them physically available. The 'dead' keys
  1433		 * report constant 0. As all map to the same keycode, they'd confuse
  1434		 * the input layer. If we filter the 'dead' keys on the HID level, we
  1435		 * skip the keycode translation and only forward real events.
  1436		 */
  1437		if (!(field->flags & (HID_MAIN_ITEM_RELATIVE |
  1438		                      HID_MAIN_ITEM_BUFFERED_BYTE)) &&
  1439				      (field->flags & HID_MAIN_ITEM_VARIABLE) &&
  1440		    usage->usage_index < field->maxusage &&
  1441		    value == field->value[usage->usage_index])
  1442			return;
  1443	
  1444		/* report the usage code as scancode if the key status has changed */
  1445		if (usage->type == EV_KEY &&
  1446		    (!test_bit(usage->code, input->key)) == value)
  1447			input_event(input, EV_MSC, MSC_SCAN, usage->hid);
  1448	
  1449		input_event(input, usage->type, usage->code, value);
  1450	
  1451		if ((field->flags & HID_MAIN_ITEM_RELATIVE) &&
  1452		    usage->type == EV_KEY && value) {
  1453			input_sync(input);
  1454			input_event(input, usage->type, usage->code, 0);
  1455		}
  1456	}
  1457	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 19980 bytes --]

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

* Re: [PATCH v13 2/3] HID: i2c-hid-of: Expose the touchscreen-inverted properties
  2021-10-25 10:46   ` Alistair Francis
@ 2021-10-27 16:46     ` Rob Herring
  -1 siblings, 0 replies; 11+ messages in thread
From: Rob Herring @ 2021-10-27 16:46 UTC (permalink / raw)
  To: Alistair Francis
  Cc: s.hauer, benjamin.tissoires, dmitry.torokhov, shawnguo,
	alistair23, linux-kernel, linux-input, linux-imx,
	linux-arm-kernel, devicetree, jikos

On Mon, Oct 25, 2021 at 08:46:04PM +1000, Alistair Francis wrote:
> Allow the touchscreen-inverted-x/y device tree properties to control the
> HID_QUIRK_X_INVERT/HID_QUIRK_Y_INVERT quirks for the hid-input device.
> 
> Signed-off-by: Alistair Francis <alistair@alistair23.me>
> ---
>  .../devicetree/bindings/input/hid-over-i2c.txt        |  2 ++

Acked-by: Rob Herring <robh@kernel.org>

>  drivers/hid/i2c-hid/i2c-hid-acpi.c                    |  2 +-
>  drivers/hid/i2c-hid/i2c-hid-core.c                    |  4 +++-
>  drivers/hid/i2c-hid/i2c-hid-of-goodix.c               |  2 +-
>  drivers/hid/i2c-hid/i2c-hid-of.c                      | 11 ++++++++++-
>  drivers/hid/i2c-hid/i2c-hid.h                         |  2 +-
>  6 files changed, 18 insertions(+), 5 deletions(-)

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

* Re: [PATCH v13 2/3] HID: i2c-hid-of: Expose the touchscreen-inverted properties
@ 2021-10-27 16:46     ` Rob Herring
  0 siblings, 0 replies; 11+ messages in thread
From: Rob Herring @ 2021-10-27 16:46 UTC (permalink / raw)
  To: Alistair Francis
  Cc: s.hauer, benjamin.tissoires, dmitry.torokhov, shawnguo,
	alistair23, linux-kernel, linux-input, linux-imx,
	linux-arm-kernel, devicetree, jikos

On Mon, Oct 25, 2021 at 08:46:04PM +1000, Alistair Francis wrote:
> Allow the touchscreen-inverted-x/y device tree properties to control the
> HID_QUIRK_X_INVERT/HID_QUIRK_Y_INVERT quirks for the hid-input device.
> 
> Signed-off-by: Alistair Francis <alistair@alistair23.me>
> ---
>  .../devicetree/bindings/input/hid-over-i2c.txt        |  2 ++

Acked-by: Rob Herring <robh@kernel.org>

>  drivers/hid/i2c-hid/i2c-hid-acpi.c                    |  2 +-
>  drivers/hid/i2c-hid/i2c-hid-core.c                    |  4 +++-
>  drivers/hid/i2c-hid/i2c-hid-of-goodix.c               |  2 +-
>  drivers/hid/i2c-hid/i2c-hid-of.c                      | 11 ++++++++++-
>  drivers/hid/i2c-hid/i2c-hid.h                         |  2 +-
>  6 files changed, 18 insertions(+), 5 deletions(-)

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-10-27 16:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 10:46 [PATCH v13 1/3] HID: quirks: Allow inverting the absolute X/Y values Alistair Francis
2021-10-25 10:46 ` Alistair Francis
2021-10-25 10:46 ` [PATCH v13 2/3] HID: i2c-hid-of: Expose the touchscreen-inverted properties Alistair Francis
2021-10-25 10:46   ` Alistair Francis
2021-10-27 16:46   ` Rob Herring
2021-10-27 16:46     ` Rob Herring
2021-10-25 10:46 ` [PATCH v13 3/3] ARM: dts: imx7d: remarkable2: add wacom digitizer device Alistair Francis
2021-10-25 10:46   ` Alistair Francis
2021-10-26 13:30 ` [PATCH v13 1/3] HID: quirks: Allow inverting the absolute X/Y values kernel test robot
2021-10-26 13:30   ` kernel test robot
2021-10-26 13:30   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.