]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
HID: i2c-hid-of: Expose the touchscreen-inverted properties
authorAlistair Francis <alistair@alistair23.me>
Wed, 8 Dec 2021 12:40:44 +0000 (22:40 +1000)
committerPaolo Pisati <paolo.pisati@canonical.com>
Fri, 28 Jan 2022 10:02:34 +0000 (11:02 +0100)
BugLink: https://bugs.launchpad.net/bugs/1959376
[ Upstream commit b60d3c803d7603432a08aeaf988aff53b3a5ec64 ]

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>
Acked-by: Rob Herring <robh@kernel.org>
[bentiss: silence checkpatch warnings]
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20211208124045.61815-3-alistair@alistair23.me
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
Documentation/devicetree/bindings/input/hid-over-i2c.txt
drivers/hid/i2c-hid/i2c-hid-acpi.c
drivers/hid/i2c-hid/i2c-hid-core.c
drivers/hid/i2c-hid/i2c-hid-of-goodix.c
drivers/hid/i2c-hid/i2c-hid-of.c
drivers/hid/i2c-hid/i2c-hid.h

index c76bafaf98d2fc8c84aaea3d774dee37040a6e06..34c43d3bddfd197c9688f94d86bd316be801dfc5 100644 (file)
@@ -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:
 
index a6f0257a26de323a0c1af473cebdcbc8633c0c52..b96ae15e0ad917edf630132cf6fce5c87307c868 100644 (file)
@@ -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[] = {
index 517141138b007990d0335fe4c28f57d6a9626f99..4804d71e5293aa2bb058fe779b332b409d1a19cd 100644 (file)
@@ -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:
index 52674149a2750e7b138eb5def0dbacf67446dbf0..b4dad66fa954d43bc1250a17cda07bd8d18328bd 100644 (file)
@@ -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 = {
index 4bf7cea92637958b34589ab18d4e147ae6c5b8b3..97a27a803f58d2ab6c68f255c83fd989b2b2701b 100644 (file)
@@ -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,14 @@ 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[] = {
index 05a7827d211af0514ce97d30d473c70d0af45e7e..236cc062d5ef805c3da43455b951861d667d206c 100644 (file)
@@ -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);