All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Bastien Nocera <hadess@hadess.net>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>
Subject: Re: [PATCH 4/4] Input: goodix - Add pen support
Date: Wed, 8 Dec 2021 00:51:24 -0800	[thread overview]
Message-ID: <CAKdAkRTHa1oRJ1VpoFxfsKjUW7KStCXkYZ2AdB1jVCHa=pjZAA@mail.gmail.com> (raw)
In-Reply-To: <aa558a20-37d0-dbf0-740f-2813609fe3b5@redhat.com>

On Wed, Dec 8, 2021 at 12:37 AM Hans de Goede <hdegoede@redhat.com> wrote:
>
> Hi Dmitry,
>
> Thank you for the review.
>
> On 12/7/21 18:50, Dmitry Torokhov wrote:
> > On Mon, Dec 06, 2021 at 05:47:47PM +0100, Hans de Goede wrote:
> >> Some Goodix touchscreens have support for a (Goodix) active pen, add
> >> support for this. The info on how to detect when a pen is down and to
> >> detect when the stylus buttons are pressed was lifted from the out
> >> of tree Goodix driver with pen support written by Adya:
> >> https://gitlab.com/AdyaAdya/goodix-touchscreen-linux-driver/
> >>
> >> Since there is no way to tell if pen support is present, the registering
> >> of the pen input_dev is delayed till the first pen event is detected.
> >>
> >> This has been tested on a Trekstor Surftab duo W1, a Chuwi Hi13 and
> >> a Cyberbook T116 tablet.
> >>
> >> Link: https://gitlab.com/AdyaAdya/goodix-touchscreen-linux-driver/
> >> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=202161
> >> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204513
> >> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> >> ---
> >>  drivers/input/touchscreen/goodix.c | 122 ++++++++++++++++++++++++++++-
> >>  drivers/input/touchscreen/goodix.h |   1 +
> >>  2 files changed, 121 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
> >> index 2d38a941e7e4..691e4505cf4a 100644
> >> --- a/drivers/input/touchscreen/goodix.c
> >> +++ b/drivers/input/touchscreen/goodix.c
> >> @@ -298,6 +298,107 @@ static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data)
> >>      return -ENOMSG;
> >>  }
> >>
> >> +static struct input_dev *goodix_create_pen_input(struct goodix_ts_data *ts)
> >> +{
> >> +    struct device *dev = &ts->client->dev;
> >> +    struct input_dev *input;
> >> +
> >> +    input = devm_input_allocate_device(dev);
> >> +    if (!input)
> >> +            return NULL;
> >> +
> >> +    input_alloc_absinfo(input);
> >> +    if (!input->absinfo) {
> >> +            input_free_device(input);
> >> +            return NULL;
> >> +    }
> >
> > Please drop this as input_abs_set_max() will do allocation and
> > input_register_device() will reject device with ABS_* events without
> > absinfo allocated.
> >
> >> +
> >> +    input->absinfo[ABS_X] = ts->input_dev->absinfo[ABS_MT_POSITION_X];
> >
> >       input_abs_set_max(input, ABS_X,
> >               input_abs_get_max(input, ABS_MT_POSITION_X);
> >
> > or even maybe
> >
> >       input_set_abs_params(input, ABS_X,
> >               0, input_abs_get_max(input, ABS_MT_POSITION_X), 0, 0);
>
> The reason why I'm just copying the entire absinfo struct
> (and thus need the NULL check above) is because this driver uses
> touchscreen_parse_properties(), so the min and fuzz values
> might (theoretically) also be set through device-properties and
> I wanted to cover that.
>
> Since you don't like the above approach, I will go with the following
> for the next version:
>
>         input_set_abs_params(input, ABS_X,
>                              input_abs_get_min(ts->input_dev, ABS_MT_POSITION_X),
>                              input_abs_get_max(ts->input_dev, ABS_MT_POSITION_X),
>                              input_abs_get_fuzz(ts->input_dev, ABS_MT_POSITION_X),
>                              input_abs_get_flat(ts->input_dev, ABS_MT_POSITION_X));
>
> (and the same for the Y axis).

Ah, sorry, I misread the code. It is fine as is then, or we could even
consider adding input_copy_abs(input, axis, src) that would allocate
absinfo if needed, set capability, and do the copy.

Thanks.

-- 
Dmitry

  reply	other threads:[~2021-12-08  8:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06 16:47 [PATCH 0/4] Input: goodix - pen support + misc patches Hans de Goede
2021-12-06 16:47 ` [PATCH 1/4] Input: goodix - Add id->model mapping for the "9111" model Hans de Goede
2021-12-07  7:29   ` Dmitry Torokhov
2021-12-06 16:47 ` [PATCH 2/4] Input: goodix - Improve gpiod_get() error logging Hans de Goede
2021-12-07  7:31   ` Dmitry Torokhov
2021-12-07 10:07     ` Hans de Goede
2021-12-06 16:47 ` [PATCH 3/4] Input: goodix - Use the new soc_intel_is_byt() helper Hans de Goede
2021-12-06 16:47 ` [PATCH 4/4] Input: goodix - Add pen support Hans de Goede
2021-12-07 17:50   ` Dmitry Torokhov
2021-12-08  8:37     ` Hans de Goede
2021-12-08  8:51       ` Dmitry Torokhov [this message]
2021-12-08 17:02         ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKdAkRTHa1oRJ1VpoFxfsKjUW7KStCXkYZ2AdB1jVCHa=pjZAA@mail.gmail.com' \
    --to=dmitry.torokhov@gmail.com \
    --cc=hadess@hadess.net \
    --cc=hdegoede@redhat.com \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.