Received: by 10.223.164.221 with SMTP id h29csp1441308wrb; Wed, 11 Oct 2017 23:31:24 -0700 (PDT) X-Received: by 10.84.131.66 with SMTP id 60mr1296385pld.341.1507789884811; Wed, 11 Oct 2017 23:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507789884; cv=none; d=google.com; s=arc-20160816; b=zu2mQghftea5Sy1N9JCdecRgng9PgPVGdurnDLD/iEBWVx+5oyATXoh56t799dSfm5 ImASSkGO4tE2GMQ9TPA3QbukKT/KM8hiPfQSetyIerC3C4xdGnthsc5WiNfLrpCXCruD tokCau+/vfSw+FafFrYV2IGYE1W3SJ5brj+nlloNmWbkEt0X50+XBqlZJG9V1a5o8lfv mzyfKDh2wvmLZFxly+5fcJKCjhxlZ8Lz82007v4LF5NuN35wxrzUsRC/gKZYAlpgAK4E Bgw8F7nybHvvUTgURERrxl5wYw8cwUZDq/Yp2pyZ1IzJqtVdNdALlwaZVNCr9Tg9Dcrz V7Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=fYXm2X6D69TMeIidHBsjRp+8H4FPw7742g/gzRmIrew=; b=f/f3OsThMyr3P/uBO5mBzU5gLw1Zn8D3j/NZLdJuMGKSlfdyOV9593INHJtqZ5sulA DqVI0pbboNWLn0SiQcCrDTEaUH/2cnGQBL8NzZBwyWLR9dIkJPrAd8ZxEHXvu9AZ2SGF q8JdiumgDCVtzwdnf15ovi32E3paf0Oifli1qENEU09DAQ8EFwWFOZmSfeDIIYI0M/xq 49fnz+V36N750A/LEMYgNWwvlD6ahEYXPYV+5fvysfrEjo4kQhIU+vAdpBWIApfmiAFS NArcF2cx69AmmT18bDvBQdt4LJKh/7Z93Di0810tabuSISbZoRsMyjQHw+SYls6j9I8k w0Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=d5vmgnHs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10si6619565plp.477.2017.10.11.23.31.09; Wed, 11 Oct 2017 23:31:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=d5vmgnHs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752077AbdJLGaq (ORCPT + 99 others); Thu, 12 Oct 2017 02:30:46 -0400 Received: from mail-oi0-f53.google.com ([209.85.218.53]:51266 "EHLO mail-oi0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751034AbdJLGap (ORCPT ); Thu, 12 Oct 2017 02:30:45 -0400 Received: by mail-oi0-f53.google.com with SMTP id j126so6889528oib.8 for ; Wed, 11 Oct 2017 23:30:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=fYXm2X6D69TMeIidHBsjRp+8H4FPw7742g/gzRmIrew=; b=d5vmgnHsukRQVXscFq7NcXJ9GvnU9F8zq3EbCkjOSX8R7Aa1y1gI4NH4djMQ0Ugijo ruPEi+8LVo9VCnMk9nV752H6yYHMMqeEc7K9XwFMYZ4E0f1FetfaFiOSLtpTeJdVNk6Z IAuOF9Rntjh4PZv+9zZQWMAEm8qTmgKcb0VHWCtNZOd17/TtIT7UbuV5VcyHlHw9pN4j w06d4nrDfHln1CyEU9XE2XfwerzXgaCLfD0DweBqpSImq0+rhnlnXniKgzId8c+Vx+4N i6/XruNnwdGm/KaL5ZeEjc+ibVKJcglqxFSDkYwkb0UOn0QIsIUiRb8YSbL3IdMwwHfw 2tpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=fYXm2X6D69TMeIidHBsjRp+8H4FPw7742g/gzRmIrew=; b=tcALvnHDq52ToEWOYPqUFr30x3/08DAFMycW9QigESEVKVPCt11ldaAjPenVMvcP9x rRyFB2BBGWSG7QCmqTXnzz4ln6JoVUOBdRXjZwsAIWKyDHybZU+Sds5ggo0ncwTe+cmL 0rw6csxr/G4FiVZ7MsZQEARxXZqbdAoGzmorcE7UZ9g+7+4heSw6/WEsiwwCQkwRWWMD LIDlcupKqtC6EvQGK5P96YY7JMmE3j68/160Db1Idup2+c2Vvy/7dbbs9LcEjqpGnHgO 7oEROn6xs8hwHjIDR+3zQwyS0hrtGPw3zIeMtoAsaVio0n2W73NaC3yc74f0rX5cXniM mRCw== X-Gm-Message-State: AMCzsaX6BYPo4aGe7ZrSV/h8Q4pKWhHrc3rp1KUzkGbbNj7Won/GoFLc 2XxMqmkbY0H4SWfnYR/fRvTtssZ3DIdCis/1j3V4hyvo X-Google-Smtp-Source: AOwi7QDZwjjbkY87jDhfeQMz9xjhsYFg3M+/nTuIQbB3aDjMkqvoFR11OAEGoi1GZCZnWrkaBgbWM7l2vpiTwcrJSsU= X-Received: by 10.202.199.84 with SMTP id x81mr678532oif.67.1507789842138; Wed, 11 Oct 2017 23:30:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.66.205 with HTTP; Wed, 11 Oct 2017 23:30:41 -0700 (PDT) In-Reply-To: <20171012062143.39785-1-wnhuang@google.com> References: <20171012062143.39785-1-wnhuang@google.com> From: Wei-Ning Huang Date: Thu, 12 Oct 2017 14:30:41 +0800 Message-ID: Subject: Re: [PATCH v5] HID: hid-multitouch: support fine-grain orientation reporting To: LKML , Linux Input Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry I forgot to remove the S-o-b of my Google email. Henrik can you help me remove that line if you pick it? Thanks. Wei-Ning On Thu, Oct 12, 2017 at 2:21 PM, Wei-Ning Huang wrot= e: > From: Wei-Ning Huang > > The current hid-multitouch driver only allow the report of two > orientations, vertical and horizontal. We use the Azimuth orientation > usage 0x3F under the Digitizer usage page to report orientation if the > device supports it. > > Changelog: > v1 -> v2: > - Fix commit message. > - Remove resolution reporting for ABS_MT_ORIENTATION. > v2 -> v3: > - Fix commit message. > v3 -> v4: > - Fix ABS_MT_ORIENTATION ABS param range. > - Don't set ABS_MT_ORIENTATION in ABS_DG_HEIGHT when it is already > set by ABS_DG_AZIMUTH. > v4 -> v5: > - Improve multi-touch-protocol.rst documentation. > > Signed-off-by: Wei-Ning Huang > Signed-off-by: Wei-Ning Huang > Reviewed-by: Dmitry Torokhov > --- > Documentation/input/multi-touch-protocol.rst | 9 ++--- > drivers/hid/hid-multitouch.c | 52 ++++++++++++++++++++++= +++--- > include/linux/hid.h | 1 + > 3 files changed, 54 insertions(+), 8 deletions(-) > > diff --git a/Documentation/input/multi-touch-protocol.rst b/Documentation= /input/multi-touch-protocol.rst > index 8035868c56bc..b51751a0cd5d 100644 > --- a/Documentation/input/multi-touch-protocol.rst > +++ b/Documentation/input/multi-touch-protocol.rst > @@ -269,10 +269,11 @@ ABS_MT_ORIENTATION > The orientation of the touching ellipse. The value should describe a= signed > quarter of a revolution clockwise around the touch center. The signe= d value > range is arbitrary, but zero should be returned for an ellipse align= ed with > - the Y axis of the surface, a negative value when the ellipse is turn= ed to > - the left, and a positive value when the ellipse is turned to the > - right. When completely aligned with the X axis, the range max should= be > - returned. > + the Y axis (north) of the surface, a negative value when the ellipse= is > + turned to the left, and a positive value when the ellipse is turned = to the > + right. When aligned with the X axis in the positive direction, the r= ange > + max should be returned; when aligned with the X axis in the negative > + direction, the range -max should be returned. > > Touch ellipsis are symmetrical by default. For devices capable of tr= ue 360 > degree orientation, the reported orientation must exceed the range m= ax to > diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c > index 440b999304a5..3317dae64ef7 100644 > --- a/drivers/hid/hid-multitouch.c > +++ b/drivers/hid/hid-multitouch.c > @@ -84,11 +84,12 @@ MODULE_LICENSE("GPL"); > #define MT_IO_FLAGS_PENDING_SLOTS 2 > > struct mt_slot { > - __s32 x, y, cx, cy, p, w, h; > + __s32 x, y, cx, cy, p, w, h, a; > __s32 contactid; /* the device ContactID assigned to this = slot */ > bool touch_state; /* is the touch valid? */ > bool inrange_state; /* is the finger in proximity of the sens= or? */ > bool confidence_state; /* is the touch made by a finger? */ > + bool has_azimuth; /* the contact reports azimuth */ > }; > > struct mt_class { > @@ -571,8 +572,15 @@ static int mt_touch_input_mapping(struct hid_device = *hdev, struct hid_input *hi, > if (!(cls->quirks & MT_QUIRK_NO_AREA)) { > set_abs(hi->input, ABS_MT_TOUCH_MINOR, fi= eld, > cls->sn_height); > - input_set_abs_params(hi->input, > - ABS_MT_ORIENTATION, 0, 1, 0, 0); > + > + /* > + * Only set ABS_MT_ORIENTATION if it is n= ot > + * already set by the HID_DG_AZIMUTH usag= e. > + */ > + if (!test_bit(ABS_MT_ORIENTATION, > + hi->input->absbit)) > + input_set_abs_params(hi->input, > + ABS_MT_ORIENTATION, 0, 1,= 0, 0); > } > mt_store_field(usage, td, hi); > return 1; > @@ -591,6 +599,21 @@ static int mt_touch_input_mapping(struct hid_device = *hdev, struct hid_input *hi, > td->cc_index =3D field->index; > td->cc_value_index =3D usage->usage_index; > return 1; > + case HID_DG_AZIMUTH: > + hid_map_usage(hi, usage, bit, max, > + EV_ABS, ABS_MT_ORIENTATION); > + /* > + * Azimuth has the range of [0, MAX) representing= a full > + * revolution. Set ABS_MT_ORIENTATION to a quarte= r of > + * MAX according the definition of ABS_MT_ORIENTA= TION > + */ > + input_set_abs_params(hi->input, ABS_MT_ORIENTATIO= N, > + -field->logical_maximum / 4, > + field->logical_maximum / 4, > + cls->sn_move ? > + field->logical_maximum / cls->sn_move : 0= , 0); > + mt_store_field(usage, td, hi); > + return 1; > case HID_DG_CONTACTMAX: > /* we don't set td->last_slot_field as contactcou= nt and > * contact max are global to the report */ > @@ -683,6 +706,10 @@ static void mt_complete_slot(struct mt_device *td, s= truct input_dev *input) > int wide =3D (s->w > s->h); > int major =3D max(s->w, s->h); > int minor =3D min(s->w, s->h); > + int orientation =3D wide; > + > + if (s->has_azimuth) > + orientation =3D s->a; > > /* > * divided by two to match visual scale of touch > @@ -699,7 +726,8 @@ static void mt_complete_slot(struct mt_device *td, st= ruct input_dev *input) > input_event(input, EV_ABS, ABS_MT_TOOL_Y, s->cy); > input_event(input, EV_ABS, ABS_MT_DISTANCE, > !s->touch_state); > - input_event(input, EV_ABS, ABS_MT_ORIENTATION, wi= de); > + input_event(input, EV_ABS, ABS_MT_ORIENTATION, > + orientation); > input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p)= ; > input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, ma= jor); > input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, mi= nor); > @@ -789,6 +817,22 @@ static void mt_process_mt_event(struct hid_device *h= id, struct hid_field *field, > break; > case HID_DG_CONTACTCOUNT: > break; > + case HID_DG_AZIMUTH: > + /* > + * Azimuth is counter-clockwise and ranges from [= 0, MAX) > + * (a full revolution). Convert it to clockwise r= anging > + * [-MAX/2, MAX/2]. > + * > + * Note that ABS_MT_ORIENTATION require us to rep= ort > + * the limit of [-MAX/4, MAX/4], but the value ca= n go > + * out of range to [-MAX/2, MAX/2] to report an u= pside > + * down ellipsis. > + */ > + if (value > field->logical_maximum / 2) > + value -=3D field->logical_maximum; > + td->curdata.a =3D -value; > + td->curdata.has_azimuth =3D true; > + break; > case HID_DG_TOUCH: > /* do nothing */ > break; > diff --git a/include/linux/hid.h b/include/linux/hid.h > index ab05a86269dc..d81b9b6fd83a 100644 > --- a/include/linux/hid.h > +++ b/include/linux/hid.h > @@ -281,6 +281,7 @@ struct hid_item { > > #define HID_DG_DEVICECONFIG 0x000d000e > #define HID_DG_DEVICESETTINGS 0x000d0023 > +#define HID_DG_AZIMUTH 0x000d003f > #define HID_DG_CONFIDENCE 0x000d0047 > #define HID_DG_WIDTH 0x000d0048 > #define HID_DG_HEIGHT 0x000d0049 > -- > 2.12.2 > --=20 Wei-Ning Huang, =E9=BB=83=E5=81=89=E5=AF=A7 | Software Engineer, Google Inc= ., Taiwan | wnhuang@google.com | Cell: +886 910-380678 From 1581031818844880283@xxx Thu Oct 12 06:23:59 +0000 2017 X-GM-THRID: 1581031818844880283 X-Gmail-Labels: Inbox,Category Forums