linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@enac.fr>
To: Henrik Rydberg <rydberg@euromail.se>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Ping Cheng <pingc@wacom.com>, Jiri Kosina <jkosina@suse.cz>,
	Chris Bagwell <chris@cnpbagwell.com>,
	Rafi Rubin <rafi@seas.upenn.edu>,
	Stephane Chatty <chatty@lii-enac.fr>,
	Peter Hutterer <peter.hutterer@who-t.net>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC 1/2] input: mt: Add method to extract the MT slot state
Date: Thu, 27 Jan 2011 13:49:18 +0100	[thread overview]
Message-ID: <AANLkTim7DbxhEO7vHPFcC1PFf=d2mSEyL+wurzUQa0pg@mail.gmail.com> (raw)
In-Reply-To: <20110127120603.GB15626@polaris.bitmath.org>

Hi Henrik,

On Thu, Jan 27, 2011 at 13:06, Henrik Rydberg <rydberg@euromail.se> wrote:
> Hi Benjamin,
>
> On Thu, Jan 27, 2011 at 11:35:46AM +0100, Benjamin Tissoires wrote:
>> This patch adds the function input_mt_get_abs_value(), which may be
>
> Ehm, input_mt_get_absinfo?

In fact, the idea was to put this on the table again ;). I have no
idea of what is the right think to do in such case.
So I'll take all comments.

>
>> used to extract the current state of the MT slots.
>>
>> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
>
> I had rather re-add this myself, thanks.

That was my question. Plus I had a subliminal message in which I
intend you to take the drive on this work. ;)

>
>> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
>> ---
>>  drivers/input/input-mt.c |   32 ++++++++++++++++++++++++++++++++
>>  include/linux/input/mt.h |    1 +
>>  2 files changed, 33 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
>> index c48c81f..5b95e38 100644
>> --- a/drivers/input/input-mt.c
>> +++ b/drivers/input/input-mt.c
>> @@ -168,3 +168,35 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
>>       }
>>  }
>>  EXPORT_SYMBOL(input_mt_report_pointer_emulation);
>> +
>> +/**
>> + * input_mt_get_absinfo - retrieve MT state variables from a device slot
>> + * @dev: input device which state is being queried
>> + * @code: ABS code to retrieve
>> + * @slot: slot to retrieve from
>> + *
>> + * Return the ABS state of the given MT slot. If code is not an MT
>> + * event, the corresponding ABS event is returned.
>> + *
>> + * This function may be called by anyone interested in extracting the
>> + * current MT state. Used by evdev handlers.
>> + */
>> +struct input_absinfo input_mt_get_absinfo(struct input_dev *dev, unsigned int code, int slot)
>
> Why return the struct? Give it a pointer instead, so the return value
> can be used for errors.

Quick and dirty think. Maybe the old implementation is better.

>
> Also, I wonder about the usefulness of extracting the absinfo here -
> only the value depends on the slot argument, and absinfo does not
> require the same lock protection. Why not keep the layout from the
> original patch?

same above

>
>> +{
>> +     unsigned int mtmap = code > ABS_MT_FIRST ? code - ABS_MT_FIRST : 0;
>
> Should rather return -EINVAL on bad argument.

I did not know how to handle the original code:
"unsigned int mtmap = input_mt_abs_map[code];"

Now I know.

>
>> +     unsigned long flags;
>> +     struct input_absinfo retval;
>> +
>> +     spin_lock_irqsave(&dev->event_lock, flags);
>> +     if (!mtmap)
>> +             retval = dev->absinfo[code];
>> +     else if (slot >= 0 && slot < dev->mtsize) {
>> +             retval = dev->absinfo[code];
>> +             retval.value = dev->mt[slot].abs[mtmap];
>
> Please use input_mt_get_value().

This is a problem when working with code that was send 6 months ago.

>
>> +     } else
>> +             retval.value = 0;
>> +     spin_unlock_irqrestore(&dev->event_lock, flags);
>> +
>> +     return retval;
>> +}
>> +EXPORT_SYMBOL(input_mt_get_absinfo);
>> diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h
>> index b3ac06a..a71a27f 100644
>> --- a/include/linux/input/mt.h
>> +++ b/include/linux/input/mt.h
>> @@ -54,4 +54,5 @@ void input_mt_report_slot_state(struct input_dev *dev,
>>  void input_mt_report_finger_count(struct input_dev *dev, int count);
>>  void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count);
>>
>> +struct input_absinfo input_mt_get_absinfo(struct input_dev *dev, unsigned int code, int slot);
>>  #endif
>
> Thanks,
> Henrik
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-01-27 12:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-27 10:35 [RFC 0/2] Add EVIOC mechanism to extract the MT slot state Benjamin Tissoires
2011-01-27 10:35 ` [RFC 1/2] input: mt: Add method " Benjamin Tissoires
2011-01-27 10:35 ` [RFC 2/2] input: evdev: Add EVIOC mechanism " Benjamin Tissoires
     [not found] ` <1296124547-3323-2-git-send-email-benjamin.tissoires@enac.fr>
2011-01-27 12:06   ` [RFC 1/2] input: mt: Add method " Henrik Rydberg
2011-01-27 12:49     ` Benjamin Tissoires [this message]
2011-01-28 17:33       ` Henrik Rydberg
2011-01-28 18:10         ` Benjamin Tissoires
2011-01-28 18:34           ` Henrik Rydberg
     [not found] ` <1296124547-3323-3-git-send-email-benjamin.tissoires@enac.fr>
2011-01-27 12:09   ` [RFC 2/2] input: evdev: Add EVIOC mechanism " Henrik Rydberg
2011-01-28 17:39     ` Dmitry Torokhov

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='AANLkTim7DbxhEO7vHPFcC1PFf=d2mSEyL+wurzUQa0pg@mail.gmail.com' \
    --to=benjamin.tissoires@enac.fr \
    --cc=chatty@lii-enac.fr \
    --cc=chris@cnpbagwell.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.hutterer@who-t.net \
    --cc=pingc@wacom.com \
    --cc=rafi@seas.upenn.edu \
    --cc=rydberg@euromail.se \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).