mbox series

[0/2] Input: Add ektf2232 support

Message ID 20240502185819.788716-1-andreas@kemnade.info
Headers show
Series Input: Add ektf2232 support | expand

Message

Andreas Kemnade May 2, 2024, 6:58 p.m. UTC
Add support for the EKTF2232 to the ektf2127 driver which
contains support for similar chips.

Add the needed compatible to bindings and convert them.

Andreas Kemnade (2):
  dt-bindings: touchscreen: convert elan,ektf2127 to json-schema
  Input: ektf2127 - add ektf2232 support

 .../bindings/input/touchscreen/ektf2127.txt   | 25 --------
 .../input/touchscreen/elan,ektf2127.yaml      | 59 +++++++++++++++++++
 drivers/input/touchscreen/ektf2127.c          | 15 ++++-
 3 files changed, 72 insertions(+), 27 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/ektf2127.txt
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/elan,ektf2127.yaml

Comments

Andy Shevchenko May 2, 2024, 7:16 p.m. UTC | #1
On Thu, May 2, 2024 at 9:58 PM Andreas Kemnade <andreas@kemnade.info> wrote:
>
> The chip is similar, but has status bits at different positions,
> so use the correct bits.

...

> +       if (ts->shifted_status) {
> +               ektf2127_report2_contact(ts, 0, &buf[1], !!(buf[7] & 1));
> +               ektf2127_report2_contact(ts, 1, &buf[4], !!(buf[7] & 2));

BIT(0)
BIT(1)

> +       } else {
> +               ektf2127_report2_contact(ts, 0, &buf[1], !!(buf[7] & 2));
> +               ektf2127_report2_contact(ts, 1, &buf[4], !!(buf[7] & 4));

BIT(1)
BIT(2)

> +       }

...

> +       if (dev->of_node &&
> +           of_device_is_compatible(dev->of_node, "elan,ektf2232"))

if (device_is_compatible(...))

> +               ts->shifted_status = true;
Dmitry Torokhov May 2, 2024, 11:10 p.m. UTC | #2
On Thu, May 02, 2024 at 10:16:01PM +0300, Andy Shevchenko wrote:
> On Thu, May 2, 2024 at 9:58 PM Andreas Kemnade <andreas@kemnade.info> wrote:
> >
> > The chip is similar, but has status bits at different positions,
> > so use the correct bits.
> 
> ...
> 
> > +       if (ts->shifted_status) {

Instead of the flag I think it would be better if you had
ts->status_shift and did

		status = buf[7] >> ts->status_shift;
		ektf2127_report2_contact(ts, 0, &buf[1], status & BIT(0));
		ektf2127_report2_contact(ts, 1, &buf[4], status & BIT(1));

> > +               ektf2127_report2_contact(ts, 0, &buf[1], !!(buf[7] & 1));
> > +               ektf2127_report2_contact(ts, 1, &buf[4], !!(buf[7] & 2));
> 
> BIT(0)
> BIT(1)
> 
> > +       } else {
> > +               ektf2127_report2_contact(ts, 0, &buf[1], !!(buf[7] & 2));
> > +               ektf2127_report2_contact(ts, 1, &buf[4], !!(buf[7] & 4));
> 
> BIT(1)
> BIT(2)
> 
> > +       }
> 
> ...
> 
> > +       if (dev->of_node &&
> > +           of_device_is_compatible(dev->of_node, "elan,ektf2232"))
> 
> if (device_is_compatible(...))

Actually I think this better come from data obtained via
device_get_match_data().

> 
> > +               ts->shifted_status = true;
> 

Thanks.
Andy Shevchenko May 3, 2024, 3:37 a.m. UTC | #3
On Fri, May 3, 2024 at 2:10 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Thu, May 02, 2024 at 10:16:01PM +0300, Andy Shevchenko wrote:
> > On Thu, May 2, 2024 at 9:58 PM Andreas Kemnade <andreas@kemnade.info> wrote:

...

> > > +       if (ts->shifted_status) {
>
> Instead of the flag I think it would be better if you had
> ts->status_shift and did
>
>                 status = buf[7] >> ts->status_shift;
>                 ektf2127_report2_contact(ts, 0, &buf[1], status & BIT(0));
>                 ektf2127_report2_contact(ts, 1, &buf[4], status & BIT(1));
>
> > > +               ektf2127_report2_contact(ts, 0, &buf[1], !!(buf[7] & 1));
> > > +               ektf2127_report2_contact(ts, 1, &buf[4], !!(buf[7] & 2));
> >
> > BIT(0)
> > BIT(1)
> >
> > > +       } else {
> > > +               ektf2127_report2_contact(ts, 0, &buf[1], !!(buf[7] & 2));
> > > +               ektf2127_report2_contact(ts, 1, &buf[4], !!(buf[7] & 4));
> >
> > BIT(1)
> > BIT(2)
> >
> > > +       }

...

> > > +       if (dev->of_node &&
> > > +           of_device_is_compatible(dev->of_node, "elan,ektf2232"))
> >
> > if (device_is_compatible(...))
>
> Actually I think this better come from data obtained via
> device_get_match_data().
>
> > > +               ts->shifted_status = true;

I agree with your comments. Hopefully the author as well.