From patchwork Fri Mar 20 21:58:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 6061201 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 33B7FBF90F for ; Fri, 20 Mar 2015 21:58:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5740B204EB for ; Fri, 20 Mar 2015 21:58:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B3E8204E3 for ; Fri, 20 Mar 2015 21:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751037AbbCTV6F (ORCPT ); Fri, 20 Mar 2015 17:58:05 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:32876 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751174AbbCTV6E (ORCPT ); Fri, 20 Mar 2015 17:58:04 -0400 Received: by pabxg6 with SMTP id xg6so108318985pab.0 for ; Fri, 20 Mar 2015 14:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Sx0zJR901A2Exx3rgj4/wKfLQWg7bP9/G/Q6dQ2WxNs=; b=tae7eAIzXGRQafJs0MA5BH3LBYO0GyX9dEp6IQGSvd0ChJNGoDAQXdhulQisqcafjr KzmLNGnCp2Zkq31BF1Sh2+HGXFKe2cUNRw4cn5XDI0X8ulGuHwoAFG5MosGjrNp4Is/M /w7m0m/epF4eDv6a8p7Ec2xzHBKOnHZJDUxcCvWUVEaUUHpxu72Pnff/130eF45O3pFx DnGRcYCq+EmE0RUcMBBTDqDQUxJiJ9+XONof5CXOxW8FRFUeKh11Xq2yFWpg1ap/NVt7 H++BUYJTNmEJPuuvFtiIzUffz/N1q/9W4zowdZVRMU+bLZputp7y9YULq6rXAHf20wZU 2wkQ== X-Received: by 10.70.48.37 with SMTP id i5mr85604529pdn.111.1426888683789; Fri, 20 Mar 2015 14:58:03 -0700 (PDT) Received: from wacom-XPS-8500.wacom.com ([67.51.163.2]) by mx.google.com with ESMTPSA id xz1sm45251pbb.47.2015.03.20.14.58.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Mar 2015 14:58:03 -0700 (PDT) From: Ping Cheng X-Google-Original-From: Ping Cheng To: benjamin.tissoires@gmail.com, jkosina@suse.cz Cc: linux-input@vger.kernel.org, Ping Cheng Subject: [PATCH 3/3] HID: wacom: set stylus_in_proximity before checking touch_down Date: Fri, 20 Mar 2015 14:58:01 -0700 Message-Id: <1426888681-8755-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 In wacom_bpt_pen, we checked touch_down before assigning new stylus_in_proximity value. This would cause stylus_in_proximity not updated properly if touch is down before pen is in proximity. Signed-off-by: Ping Cheng Reviewed-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 60d9ccb..63e767e 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1752,9 +1752,6 @@ static int wacom_bpt_pen(struct wacom_wac *wacom) return 0; } - if (wacom->shared->touch_down) - return 0; - prox = (data[1] & 0x20) == 0x20; /* @@ -1767,17 +1764,21 @@ static int wacom_bpt_pen(struct wacom_wac *wacom) * * Hardware does report zero in most out-of-prox cases but not all. */ - if (prox) { - if (!wacom->shared->stylus_in_proximity) { - if (data[1] & 0x08) { - wacom->tool[0] = BTN_TOOL_RUBBER; - wacom->id[0] = ERASER_DEVICE_ID; - } else { - wacom->tool[0] = BTN_TOOL_PEN; - wacom->id[0] = STYLUS_DEVICE_ID; - } - wacom->shared->stylus_in_proximity = true; + if (!wacom->shared->stylus_in_proximity) { + if (data[1] & 0x08) { + wacom->tool[0] = BTN_TOOL_RUBBER; + wacom->id[0] = ERASER_DEVICE_ID; + } else { + wacom->tool[0] = BTN_TOOL_PEN; + wacom->id[0] = STYLUS_DEVICE_ID; } + } + + wacom->shared->stylus_in_proximity = prox; + if (wacom->shared->touch_down) + return 0; + + if (prox) { x = le16_to_cpup((__le16 *)&data[2]); y = le16_to_cpup((__le16 *)&data[4]); p = le16_to_cpup((__le16 *)&data[6]); @@ -1793,7 +1794,8 @@ static int wacom_bpt_pen(struct wacom_wac *wacom) pen = data[1] & 0x01; btn1 = data[1] & 0x02; btn2 = data[1] & 0x04; - } + } else + wacom->id[0] = 0; input_report_key(input, BTN_TOUCH, pen); input_report_key(input, BTN_STYLUS, btn1); @@ -1804,11 +1806,6 @@ static int wacom_bpt_pen(struct wacom_wac *wacom) input_report_abs(input, ABS_PRESSURE, p); input_report_abs(input, ABS_DISTANCE, d); - if (!prox) { - wacom->id[0] = 0; - wacom->shared->stylus_in_proximity = false; - } - input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */ input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */