Skip to content

Commit b60d3c8

Browse files
alistair23bentiss
authored andcommitted
HID: i2c-hid-of: Expose the touchscreen-inverted properties
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
1 parent fd8d135 commit b60d3c8

6 files changed

Lines changed: 17 additions & 5 deletions

File tree

Documentation/devicetree/bindings/input/hid-over-i2c.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ device-specific compatible properties, which should be used in addition to the
3232
- vdd-supply: phandle of the regulator that provides the supply voltage.
3333
- post-power-on-delay-ms: time required by the device after enabling its regulators
3434
or powering it on, before it is ready for communication.
35+
- touchscreen-inverted-x: See touchscreen.txt
36+
- touchscreen-inverted-y: See touchscreen.txt
3537

3638
Example:
3739

drivers/hid/i2c-hid/i2c-hid-acpi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int i2c_hid_acpi_probe(struct i2c_client *client)
111111
}
112112

113113
return i2c_hid_core_probe(client, &ihid_acpi->ops,
114-
hid_descriptor_address);
114+
hid_descriptor_address, 0);
115115
}
116116

117117
static const struct acpi_device_id i2c_hid_acpi_match[] = {

drivers/hid/i2c-hid/i2c-hid-core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ static void i2c_hid_core_shutdown_tail(struct i2c_hid *ihid)
912912
}
913913

914914
int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
915-
u16 hid_descriptor_address)
915+
u16 hid_descriptor_address, u32 quirks)
916916
{
917917
int ret;
918918
struct i2c_hid *ihid;
@@ -1009,6 +1009,8 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
10091009
goto err_mem_free;
10101010
}
10111011

1012+
hid->quirks |= quirks;
1013+
10121014
return 0;
10131015

10141016
err_mem_free:

drivers/hid/i2c-hid/i2c-hid-of-goodix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static int i2c_hid_of_goodix_probe(struct i2c_client *client,
150150
goodix_i2c_hid_deassert_reset(ihid_goodix, true);
151151
mutex_unlock(&ihid_goodix->regulator_mutex);
152152

153-
return i2c_hid_core_probe(client, &ihid_goodix->ops, 0x0001);
153+
return i2c_hid_core_probe(client, &ihid_goodix->ops, 0x0001, 0);
154154
}
155155

156156
static const struct goodix_i2c_hid_timing_data goodix_gt7375p_timing_data = {

drivers/hid/i2c-hid/i2c-hid-of.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <linux/delay.h>
2323
#include <linux/device.h>
24+
#include <linux/hid.h>
2425
#include <linux/i2c.h>
2526
#include <linux/kernel.h>
2627
#include <linux/module.h>
@@ -71,6 +72,7 @@ static int i2c_hid_of_probe(struct i2c_client *client,
7172
struct device *dev = &client->dev;
7273
struct i2c_hid_of *ihid_of;
7374
u16 hid_descriptor_address;
75+
u32 quirks = 0;
7476
int ret;
7577
u32 val;
7678

@@ -105,8 +107,14 @@ static int i2c_hid_of_probe(struct i2c_client *client,
105107
if (ret)
106108
return ret;
107109

110+
if (device_property_read_bool(dev, "touchscreen-inverted-x"))
111+
quirks |= HID_QUIRK_X_INVERT;
112+
113+
if (device_property_read_bool(dev, "touchscreen-inverted-y"))
114+
quirks |= HID_QUIRK_Y_INVERT;
115+
108116
return i2c_hid_core_probe(client, &ihid_of->ops,
109-
hid_descriptor_address);
117+
hid_descriptor_address, quirks);
110118
}
111119

112120
static const struct of_device_id i2c_hid_of_match[] = {

drivers/hid/i2c-hid/i2c-hid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct i2chid_ops {
3232
};
3333

3434
int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
35-
u16 hid_descriptor_address);
35+
u16 hid_descriptor_address, u32 quirks);
3636
int i2c_hid_core_remove(struct i2c_client *client);
3737

3838
void i2c_hid_core_shutdown(struct i2c_client *client);

0 commit comments

Comments
 (0)