From patchwork Thu Jan 8 20:06:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 5595681 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E8C5A9F443 for ; Thu, 8 Jan 2015 20:06:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 013B8204D3 for ; Thu, 8 Jan 2015 20:06:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 17D092043C for ; Thu, 8 Jan 2015 20:06:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932546AbbAHUGm (ORCPT ); Thu, 8 Jan 2015 15:06:42 -0500 Received: from mail-pd0-f173.google.com ([209.85.192.173]:49192 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932543AbbAHUGm (ORCPT ); Thu, 8 Jan 2015 15:06:42 -0500 Received: by mail-pd0-f173.google.com with SMTP id ft15so13078114pdb.4 for ; Thu, 08 Jan 2015 12:06:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=m3lkrFtS1STMnJNgu+wg9CYa1D6mKRmNOkv361/8HDU=; b=LLEzlvePAuKWjtJkICnPNkvo5WwPZAdxN1OGOkjLQYCY0YZtebHIc3hrFTjGRCWWkC liGMWYLEK7IXY6w3rPoRdCJf0YoeVEbm4mkbydHHHs40DLXeV0C5dYRwPc+eecEQIbrp PFHG8Fx+82zZEG9ZABkjnoU51fQ+W95Kvdc20Y5XBUK76N/aalUaLX/QFUnIcFcvNFxO aAUO2+melTojgc5b00G1e5BAf2wQSy8TSiiawZuoMtYk1mXbdUqwRixx8LWqIfezk/Wj QehuBhqM0nyw4XoNBSmgsbzdyg6hdY19MAbMtb/UH7ABetrq0BxKaaEO/Yli1eJCBrM7 jMXA== X-Received: by 10.70.61.37 with SMTP id m5mr7977283pdr.34.1420747601517; Thu, 08 Jan 2015 12:06:41 -0800 (PST) Received: from wacom-XPS-8500.wacom.com ([67.51.163.2]) by mx.google.com with ESMTPSA id dc8sm5180538pdb.68.2015.01.08.12.06.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Jan 2015 12:06:40 -0800 (PST) From: Ping Cheng X-Google-Original-From: Ping Cheng To: jkosina@suse.cz Cc: linux-input@vger.kernel.org, Ping Cheng Subject: [PATCH 2/2] Report In Range event according to the spec Date: Thu, 8 Jan 2015 12:06:43 -0800 Message-Id: <1420747603-22545-1-git-send-email-pingc@wacom.com> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some Citniq and Intuos tablets report In Range event. This event is sent before valid data is reported when tool enters proximity; or before out of proximity event is reported when tool exits. While erntering proximity, In Range means a pen is detected. This information can be used for palm/touch rejection on both pen and touch enabled devices. While exiting, it means the tool has reached its maximum detectable distance. Signed-off-by: Ping Cheng --- drivers/hid/wacom_wac.c | 15 ++++++++------- drivers/hid/wacom_wac.h | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 4ccf622..f93200f 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -443,9 +443,6 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) /* Enter report */ if ((data[1] & 0xfc) == 0xc0) { - if (features->quirks & WACOM_QUIRK_MULTI_INPUT) - wacom->shared->stylus_in_proximity = true; - /* serial number of the tool */ wacom->serial[idx] = ((data[3] & 0x0f) << 28) + (data[4] << 20) + (data[5] << 12) + @@ -554,19 +551,22 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) (features->type == CINTIQ && !(data[1] & 0x40))) return 1; - /* Range Report */ - if ((data[1] & 0xfe) == 0x20) { + if (features->quirks & WACOM_QUIRK_MULTI_INPUT) + wacom->shared->stylus_in_proximity = true; + + /* in Range while exiting */ + if (((data[1] & 0xfe) == 0x20) && wacom->reporting_data) { input_report_key(input, BTN_TOUCH, 0); input_report_abs(input, ABS_PRESSURE, 0); input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max); - if (features->quirks & WACOM_QUIRK_MULTI_INPUT) - wacom->shared->stylus_in_proximity = true; + return 2; } /* Exit report */ if ((data[1] & 0xfe) == 0x80) { if (features->quirks & WACOM_QUIRK_MULTI_INPUT) wacom->shared->stylus_in_proximity = false; + wacom->reporting_data = false; /* don't report exit if we don't know the ID */ if (!wacom->id[idx]) @@ -952,6 +952,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */ input_report_key(input, wacom->tool[idx], 1); input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); + wacom->reporting_data = true; return 1; } diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 7afd929..72e78cc 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -189,6 +189,7 @@ struct wacom_wac { int tool[2]; int id[2]; __u32 serial[2]; + bool reporting_data; struct wacom_features features; struct wacom_shared *shared; struct input_dev *input;