* [PATCH v3 0/3] Imagis touch keys and FIELD_GET cleanup
@ 2024-03-06 14:40 Duje Mihanović
2024-03-06 14:40 ` [PATCH v3 1/3] input: touchscreen: imagis: use FIELD_GET where applicable Duje Mihanović
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Duje Mihanović @ 2024-03-06 14:40 UTC (permalink / raw)
To: Markuss Broks, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
Cc: Karel Balej, ~postmarketos/upstreaming, phone-devel, devicetree,
linux-input, linux-kernel, Duje Mihanović
Tiny series to clean up the field extraction and add touch key support.
This version is based on the next branch of Dmitry's input tree.
Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
---
Changes in v3:
- Rebase on input/next
- Add changelog to binding patch
- Fix binding constraint
- Allow changing keycodes in userspace as in 872e57abd171 ("Input:
tm2-touchkey - allow changing keycodes from userspace")
- Allow up to 5 keycodes (the key status field has 5 bits)
- Link to v2: https://lore.kernel.org/r/20240120-b4-imagis-keys-v2-0-d7fc16f2e106@skole.hr
Changes in v2:
- Fix compile error
- Add FIELD_GET patch
- Allow specifying custom keycodes
- Link to v1: https://lore.kernel.org/20231112194124.24916-1-duje.mihanovic@skole.hr
---
Duje Mihanović (3):
input: touchscreen: imagis: use FIELD_GET where applicable
dt-bindings: input: imagis: Document touch keys
input: touchscreen: imagis: Add touch key support
.../input/touchscreen/imagis,ist3038c.yaml | 19 +++++++--
drivers/input/touchscreen/imagis.c | 46 ++++++++++++++++------
2 files changed, 50 insertions(+), 15 deletions(-)
---
base-commit: b0f3f9ab419c243389da6c0dd6a9db0eea560146
change-id: 20240120-b4-imagis-keys-a0a9f2b31740
Best regards,
--
Duje Mihanović <duje.mihanovic@skole.hr>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/3] input: touchscreen: imagis: use FIELD_GET where applicable
2024-03-06 14:40 [PATCH v3 0/3] Imagis touch keys and FIELD_GET cleanup Duje Mihanović
@ 2024-03-06 14:40 ` Duje Mihanović
2024-03-06 14:40 ` [PATCH v3 2/3] dt-bindings: input: imagis: Document touch keys Duje Mihanović
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Duje Mihanović @ 2024-03-06 14:40 UTC (permalink / raw)
To: Markuss Broks, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
Cc: Karel Balej, ~postmarketos/upstreaming, phone-devel, devicetree,
linux-input, linux-kernel, Duje Mihanović
Instead of manually extracting certain bits from registers with binary
ANDs and shifts, the FIELD_GET macro can be used. With this in mind, the
*_SHIFT macros can be dropped.
Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
---
drivers/input/touchscreen/imagis.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen/imagis.c
index e1fafa561ee3..4eae98771bd2 100644
--- a/drivers/input/touchscreen/imagis.c
+++ b/drivers/input/touchscreen/imagis.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
+#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/delay.h>
#include <linux/i2c.h>
@@ -29,12 +30,9 @@
#define IST3038C_I2C_RETRY_COUNT 3
#define IST3038C_MAX_FINGER_NUM 10
#define IST3038C_X_MASK GENMASK(23, 12)
-#define IST3038C_X_SHIFT 12
#define IST3038C_Y_MASK GENMASK(11, 0)
#define IST3038C_AREA_MASK GENMASK(27, 24)
-#define IST3038C_AREA_SHIFT 24
#define IST3038C_FINGER_COUNT_MASK GENMASK(15, 12)
-#define IST3038C_FINGER_COUNT_SHIFT 12
#define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0)
struct imagis_properties {
@@ -106,8 +104,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
goto out;
}
- finger_count = (intr_message & IST3038C_FINGER_COUNT_MASK) >>
- IST3038C_FINGER_COUNT_SHIFT;
+ finger_count = FIELD_GET(IST3038C_FINGER_COUNT_MASK, intr_message);
if (finger_count > IST3038C_MAX_FINGER_NUM) {
dev_err(&ts->client->dev,
"finger count %d is more than maximum supported\n",
@@ -115,7 +112,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
goto out;
}
- finger_pressed = intr_message & IST3038C_FINGER_STATUS_MASK;
+ finger_pressed = FIELD_GET(IST3038C_FINGER_STATUS_MASK, intr_message);
for (i = 0; i < finger_count; i++) {
if (ts->tdata->protocol_b)
@@ -136,12 +133,10 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER,
finger_pressed & BIT(i));
touchscreen_report_pos(ts->input_dev, &ts->prop,
- (finger_status & IST3038C_X_MASK) >>
- IST3038C_X_SHIFT,
- finger_status & IST3038C_Y_MASK, 1);
+ FIELD_GET(IST3038C_X_MASK, finger_status),
+ FIELD_GET(IST3038C_Y_MASK, finger_status), 1);
input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR,
- (finger_status & IST3038C_AREA_MASK) >>
- IST3038C_AREA_SHIFT);
+ FIELD_GET(IST3038C_AREA_MASK, finger_status));
}
input_mt_sync_frame(ts->input_dev);
--
2.44.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/3] dt-bindings: input: imagis: Document touch keys
2024-03-06 14:40 [PATCH v3 0/3] Imagis touch keys and FIELD_GET cleanup Duje Mihanović
2024-03-06 14:40 ` [PATCH v3 1/3] input: touchscreen: imagis: use FIELD_GET where applicable Duje Mihanović
@ 2024-03-06 14:40 ` Duje Mihanović
2024-03-07 8:11 ` Krzysztof Kozlowski
2024-03-06 14:40 ` [PATCH v3 3/3] input: touchscreen: imagis: Add touch key support Duje Mihanović
2024-03-10 5:32 ` [PATCH v3 0/3] Imagis touch keys and FIELD_GET cleanup Dmitry Torokhov
3 siblings, 1 reply; 6+ messages in thread
From: Duje Mihanović @ 2024-03-06 14:40 UTC (permalink / raw)
To: Markuss Broks, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
Cc: Karel Balej, ~postmarketos/upstreaming, phone-devel, devicetree,
linux-input, linux-kernel, Duje Mihanović
IST3032C (and possibly some other models) has touch keys. Document this.
Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
---
Changes in v3:
- Move allOf under additionalProperties and move if under allOf
- Properly define linux,keycodes
- Fix linux,keycodes constraint
- Change maximum number of keycodes to 5 in accordance with the size of
the key status field
Changes in v2:
- Allow specifying custom keycodes and document this in binding
---
.../bindings/input/touchscreen/imagis,ist3038c.yaml | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml b/Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml
index 2af71cbcc97d..77ba280b3bdc 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml
+++ b/Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml
@@ -9,9 +9,6 @@ title: Imagis IST30XXC family touchscreen controller
maintainers:
- Markuss Broks <markuss.broks@gmail.com>
-allOf:
- - $ref: touchscreen.yaml#
-
properties:
$nodename:
pattern: "^touchscreen@[0-9a-f]+$"
@@ -34,6 +31,10 @@ properties:
vddio-supply:
description: Power supply regulator for the I2C bus
+ linux,keycodes:
+ description: Keycodes for the touch keys
+ maxItems: 5
+
touchscreen-size-x: true
touchscreen-size-y: true
touchscreen-fuzz-x: true
@@ -44,6 +45,18 @@ properties:
additionalProperties: false
+allOf:
+ - $ref: touchscreen.yaml#
+ - if:
+ not:
+ properties:
+ compatible:
+ contains:
+ const: imagis,ist3032c
+ then:
+ properties:
+ linux,keycodes: false
+
required:
- compatible
- reg
--
2.44.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 3/3] input: touchscreen: imagis: Add touch key support
2024-03-06 14:40 [PATCH v3 0/3] Imagis touch keys and FIELD_GET cleanup Duje Mihanović
2024-03-06 14:40 ` [PATCH v3 1/3] input: touchscreen: imagis: use FIELD_GET where applicable Duje Mihanović
2024-03-06 14:40 ` [PATCH v3 2/3] dt-bindings: input: imagis: Document touch keys Duje Mihanović
@ 2024-03-06 14:40 ` Duje Mihanović
2024-03-10 5:32 ` [PATCH v3 0/3] Imagis touch keys and FIELD_GET cleanup Dmitry Torokhov
3 siblings, 0 replies; 6+ messages in thread
From: Duje Mihanović @ 2024-03-06 14:40 UTC (permalink / raw)
To: Markuss Broks, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
Cc: Karel Balej, ~postmarketos/upstreaming, phone-devel, devicetree,
linux-input, linux-kernel, Duje Mihanović
IST3032C (and possibly some other models) has touch keys. Add support
for them to the imagis driver.
Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
---
drivers/input/touchscreen/imagis.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen/imagis.c
index 4eae98771bd2..625d9287eabe 100644
--- a/drivers/input/touchscreen/imagis.c
+++ b/drivers/input/touchscreen/imagis.c
@@ -34,6 +34,7 @@
#define IST3038C_AREA_MASK GENMASK(27, 24)
#define IST3038C_FINGER_COUNT_MASK GENMASK(15, 12)
#define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0)
+#define IST3032C_KEY_STATUS_MASK GENMASK(20, 16)
struct imagis_properties {
unsigned int interrupt_msg_cmd;
@@ -41,6 +42,7 @@ struct imagis_properties {
unsigned int whoami_cmd;
unsigned int whoami_val;
bool protocol_b;
+ bool touch_keys_supported;
};
struct imagis_ts {
@@ -49,6 +51,8 @@ struct imagis_ts {
struct input_dev *input_dev;
struct touchscreen_properties prop;
struct regulator_bulk_data supplies[2];
+ u32 keycodes[5];
+ int num_keycodes;
};
static int imagis_i2c_read_reg(struct imagis_ts *ts,
@@ -93,7 +97,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
{
struct imagis_ts *ts = dev_id;
u32 intr_message, finger_status;
- unsigned int finger_count, finger_pressed;
+ unsigned int finger_count, finger_pressed, key_pressed;
int i;
int error;
@@ -139,6 +143,11 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
FIELD_GET(IST3038C_AREA_MASK, finger_status));
}
+ key_pressed = FIELD_GET(IST3032C_KEY_STATUS_MASK, intr_message);
+
+ for (int i = 0; i < ts->num_keycodes; i++)
+ input_report_key(ts->input_dev, ts->keycodes[i], (key_pressed & BIT(i)));
+
input_mt_sync_frame(ts->input_dev);
input_sync(ts->input_dev);
@@ -224,6 +233,23 @@ static int imagis_init_input_dev(struct imagis_ts *ts)
input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X);
input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 16, 0, 0);
+ if (ts->tdata->touch_keys_supported) {
+ ts->num_keycodes = of_property_read_variable_u32_array(
+ ts->client->dev.of_node, "linux,keycodes",
+ ts->keycodes, 0, ARRAY_SIZE(ts->keycodes));
+ if (ts->num_keycodes <= 0) {
+ ts->keycodes[0] = KEY_APPSELECT;
+ ts->keycodes[1] = KEY_BACK;
+ ts->num_keycodes = 2;
+ }
+
+ input_dev->keycodemax = ts->num_keycodes;
+ input_dev->keycodesize = sizeof(ts->keycodes[0]);
+ input_dev->keycode = ts->keycodes;
+ }
+
+ for (int i = 0; i < ts->num_keycodes; i++)
+ input_set_capability(input_dev, EV_KEY, ts->keycodes[i]);
touchscreen_parse_properties(input_dev, true, &ts->prop);
if (!ts->prop.max_x || !ts->prop.max_y) {
@@ -365,6 +391,7 @@ static const struct imagis_properties imagis_3032c_data = {
.touch_coord_cmd = IST3038C_REG_TOUCH_COORD,
.whoami_cmd = IST3038C_REG_CHIPID,
.whoami_val = IST3032C_WHOAMI,
+ .touch_keys_supported = true,
};
static const struct imagis_properties imagis_3038b_data = {
--
2.44.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 2/3] dt-bindings: input: imagis: Document touch keys
2024-03-06 14:40 ` [PATCH v3 2/3] dt-bindings: input: imagis: Document touch keys Duje Mihanović
@ 2024-03-07 8:11 ` Krzysztof Kozlowski
0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2024-03-07 8:11 UTC (permalink / raw)
To: Duje Mihanović, Markuss Broks, Dmitry Torokhov, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Karel Balej, ~postmarketos/upstreaming, phone-devel, devicetree,
linux-input, linux-kernel
On 06/03/2024 15:40, Duje Mihanović wrote:
> IST3032C (and possibly some other models) has touch keys. Document this.
>
> Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
> ---
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/3] Imagis touch keys and FIELD_GET cleanup
2024-03-06 14:40 [PATCH v3 0/3] Imagis touch keys and FIELD_GET cleanup Duje Mihanović
` (2 preceding siblings ...)
2024-03-06 14:40 ` [PATCH v3 3/3] input: touchscreen: imagis: Add touch key support Duje Mihanović
@ 2024-03-10 5:32 ` Dmitry Torokhov
3 siblings, 0 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2024-03-10 5:32 UTC (permalink / raw)
To: Duje Mihanović
Cc: Markuss Broks, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Karel Balej, ~postmarketos/upstreaming, phone-devel, devicetree,
linux-input, linux-kernel
On Wed, Mar 06, 2024 at 03:40:05PM +0100, Duje Mihanović wrote:
> Tiny series to clean up the field extraction and add touch key support.
> This version is based on the next branch of Dmitry's input tree.
>
> Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
> ---
> Changes in v3:
> - Rebase on input/next
> - Add changelog to binding patch
> - Fix binding constraint
> - Allow changing keycodes in userspace as in 872e57abd171 ("Input:
> tm2-touchkey - allow changing keycodes from userspace")
> - Allow up to 5 keycodes (the key status field has 5 bits)
> - Link to v2: https://lore.kernel.org/r/20240120-b4-imagis-keys-v2-0-d7fc16f2e106@skole.hr
>
> Changes in v2:
> - Fix compile error
> - Add FIELD_GET patch
> - Allow specifying custom keycodes
> - Link to v1: https://lore.kernel.org/20231112194124.24916-1-duje.mihanovic@skole.hr
>
> ---
> Duje Mihanović (3):
> input: touchscreen: imagis: use FIELD_GET where applicable
> dt-bindings: input: imagis: Document touch keys
> input: touchscreen: imagis: Add touch key support
>
> .../input/touchscreen/imagis,ist3038c.yaml | 19 +++++++--
> drivers/input/touchscreen/imagis.c | 46 ++++++++++++++++------
> 2 files changed, 50 insertions(+), 15 deletions(-)
Applied the lot, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-03-10 5:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-06 14:40 [PATCH v3 0/3] Imagis touch keys and FIELD_GET cleanup Duje Mihanović
2024-03-06 14:40 ` [PATCH v3 1/3] input: touchscreen: imagis: use FIELD_GET where applicable Duje Mihanović
2024-03-06 14:40 ` [PATCH v3 2/3] dt-bindings: input: imagis: Document touch keys Duje Mihanović
2024-03-07 8:11 ` Krzysztof Kozlowski
2024-03-06 14:40 ` [PATCH v3 3/3] input: touchscreen: imagis: Add touch key support Duje Mihanović
2024-03-10 5:32 ` [PATCH v3 0/3] Imagis touch keys and FIELD_GET cleanup Dmitry Torokhov
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.