All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Henrik Rydberg" <rydberg@euromail.se>
To: "benjamin.tissoires" <benjamin.tissoires@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Jiri Kosina <jkosina@suse.cz>, Stephane Chatty <chatty@enac.fr>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] HID: hid-multitouch: fix input mode feature command
Date: Wed, 20 Jun 2012 18:32:38 +0200	[thread overview]
Message-ID: <20120620163238.GA447@polaris.bitmath.org> (raw)
In-Reply-To: <1340109594-10732-1-git-send-email-benjamin.tissoires@gmail.com>

Hi Benjamin,

> Zytronic panels shows a new way of setting the Input Mode feature.
> This feature is put in the second usage in the HID feature, instead
> of the first, as the majority of the multitouch devices.
> 
> This patch adds a detection step when the feature is presented to know
> where the feature is located in the report. We can then trigger the right
> command to the device. This removes the magic number "0" in the function
> mt_set_input_mode.
> 
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
> ---
>  drivers/hid/hid-multitouch.c |   13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
> index 61cc4cb..9a3891e 100644
> --- a/drivers/hid/hid-multitouch.c
> +++ b/drivers/hid/hid-multitouch.c
> @@ -83,6 +83,7 @@ struct mt_device {
>  	unsigned last_field_index;	/* last field index of the report */
>  	unsigned last_slot_field;	/* the last field of a slot */
>  	__s8 inputmode;		/* InputMode HID feature, -1 if non-existent */
> +	__s8 inputmode_index;	/* InputMode HID feature index in the report */
>  	__s8 maxcontact_report_id;	/* Maximum Contact Number HID feature,
>  				   -1 if non-existent */
>  	__u8 num_received;	/* how many contacts we received */
> @@ -260,10 +261,20 @@ static void mt_feature_mapping(struct hid_device *hdev,
>  		struct hid_field *field, struct hid_usage *usage)
>  {
>  	struct mt_device *td = hid_get_drvdata(hdev);
> +	int i;

Or a separate function to keep thing neat?

>  
>  	switch (usage->hid) {
>  	case HID_DG_INPUTMODE:
>  		td->inputmode = field->report->id;
> +		td->inputmode_index = 0; /* has to be updated below */

Isn't this zero already?

> +
> +		for (i=0; i < field->maxusage; i++) {
> +			if (field->usage[i].hid == usage->hid) {
> +				td->inputmode_index = i;
> +				break;

The break here is an optimization of the dubious kind. ;-)
Or do we expect more than one occurence?

> +			}
> +		}
> +
>  		break;
>  	case HID_DG_CONTACTMAX:
>  		td->maxcontact_report_id = field->report->id;
> @@ -618,7 +629,7 @@ static void mt_set_input_mode(struct hid_device *hdev)
>  	re = &(hdev->report_enum[HID_FEATURE_REPORT]);
>  	r = re->report_id_hash[td->inputmode];
>  	if (r) {
> -		r->field[0]->value[0] = 0x02;
> +		r->field[0]->value[td->inputmode_index] = 0x02;
>  		usbhid_submit_report(hdev, r, USB_DIR_OUT);
>  	}
>  }
> -- 
> 1.7.10.2
> 

Thanks,
Henrik

  parent reply	other threads:[~2012-06-20 16:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-19 12:39 [PATCH 1/3] HID: hid-multitouch: fix input mode feature command benjamin.tissoires
2012-06-19 12:39 ` [PATCH 2/3] HID: hid-multitouch: support arrays for the split of the touches in a report benjamin.tissoires
2012-06-20 16:53   ` Henrik Rydberg
2012-06-19 12:39 ` [PATCH 3/3] HID: hid-multitouch: add support for Zytronic panels benjamin.tissoires
2012-06-20 16:32 ` Henrik Rydberg [this message]
2012-06-28  8:31 ` [PATCH 1/3] HID: hid-multitouch: fix input mode feature command Jiri Kosina
2012-06-28 10:08   ` Benjamin Tissoires
2012-06-28 10:10     ` Jiri Kosina

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=20120620163238.GA447@polaris.bitmath.org \
    --to=rydberg@euromail.se \
    --cc=benjamin.tissoires@gmail.com \
    --cc=chatty@enac.fr \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@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.