From patchwork Tue Dec 1 01:13:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 7731721 X-Patchwork-Delegate: jikos@jikos.cz 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 F05A79F54F for ; Tue, 1 Dec 2015 01:14:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DCA7920641 for ; Tue, 1 Dec 2015 01:14:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4C4220663 for ; Tue, 1 Dec 2015 01:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754314AbbLABN6 (ORCPT ); Mon, 30 Nov 2015 20:13:58 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:36709 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752024AbbLABN5 (ORCPT ); Mon, 30 Nov 2015 20:13:57 -0500 Received: by pacdm15 with SMTP id dm15so202576021pac.3 for ; Mon, 30 Nov 2015 17:13:56 -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:in-reply-to:references; bh=7d+eBkmBL11GQaYOsQXVt1rWc7imLS9TtP741IN6qx8=; b=jsZ6LpGzSVdmmGdmIaRNH7iulIbksr2qkV02B6PYzGxL+udWQGrUBT5f0qHpYN3xPj SEBkKTWuYX0KfEa7xhtRut6GgDo3kaZcO4PE1BH/JlguG+cYVmSl8iROMpm02n+R+hNI 58hvliA4mPEOL+6bgOdRe51T0417hUJoMTS5EXsnGrBtEElR06Ae+uOfZiCKXSfhqCgQ fuGgjRehRFrLwALT7F5gBV/4q85dEjMw56HTbl2TM0fIaGFEPKQSDA+wHqmh86R4N3BL ciU9Q8ImxXj97lBdLfQgh9IyoaEvEOWlNLqaqPPF8jq2hjBMZL2GLcy2I4ktI3zU9MJ/ oueA== X-Received: by 10.98.72.152 with SMTP id q24mr76128268pfi.156.1448932436743; Mon, 30 Nov 2015 17:13:56 -0800 (PST) Received: from wacom-arch2.corp.onewacom.com ([67.51.163.2]) by smtp.gmail.com with ESMTPSA id vq2sm10654740pab.42.2015.11.30.17.13.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Nov 2015 17:13:56 -0800 (PST) From: Jason Gerecke To: linux-input@vger.kernel.org Cc: Jiri Kosina , Ping Cheng , Aaron Skomra , Jason Gerecke , Jason Gerecke Subject: [PATCH 3/7] HID: wacom: Centralize Intuos pen packet decoding Date: Mon, 30 Nov 2015 17:13:48 -0800 Message-Id: <1448932432-10115-3-git-send-email-killertofu@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1448932432-10115-1-git-send-email-killertofu@gmail.com> References: <1448932432-10115-1-git-send-email-killertofu@gmail.com> 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 Continue to slim down 'wacom_intuos_irq' by moving all decoding and reporting of pen packet data into the 'wacom_intuos_general' function. Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 105 +++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index ec1e13e..e395688 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -880,13 +880,28 @@ static int wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len) return 0; } -static void wacom_intuos_general(struct wacom_wac *wacom) +static int wacom_intuos_general(struct wacom_wac *wacom) { struct wacom_features *features = &wacom->features; unsigned char *data = wacom->data; struct input_dev *input = wacom->pen_input; + int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; unsigned int t; + if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ && + data[0] != WACOM_REPORT_INTUOS_PEN) + return 0; + + if (features->type >= INTUOS3S) { + input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); + input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); + input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); + } else { + input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2])); + input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4])); + input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); + } + /* general pen packet */ if ((data[1] & 0xb8) == 0xa0) { t = (data[6] << 2) | ((data[7] >> 6) & 3); @@ -912,55 +927,6 @@ static void wacom_intuos_general(struct wacom_wac *wacom) (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); } -} - -static int wacom_intuos_irq(struct wacom_wac *wacom) -{ - struct wacom_features *features = &wacom->features; - unsigned char *data = wacom->data; - struct input_dev *input = wacom->pen_input; - unsigned int t; - int idx = 0, result; - - if (data[0] != WACOM_REPORT_PENABLED && - data[0] != WACOM_REPORT_INTUOSREAD && - data[0] != WACOM_REPORT_INTUOSWRITE && - data[0] != WACOM_REPORT_INTUOSPAD && - data[0] != WACOM_REPORT_INTUOS_PEN && - data[0] != WACOM_REPORT_CINTIQ && - data[0] != WACOM_REPORT_CINTIQPAD && - data[0] != WACOM_REPORT_INTUOS5PAD) { - dev_dbg(input->dev.parent, - "%s: received unknown report #%d\n", __func__, data[0]); - return 0; - } - - /* tool number */ - if (features->type == INTUOS) - idx = data[1] & 0x01; - - /* process pad events */ - result = wacom_intuos_pad(wacom); - if (result) - return result; - - /* process in/out prox events */ - result = wacom_intuos_inout(wacom); - if (result) - return result - 1; - - if (features->type >= INTUOS3S) { - input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); - input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); - input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); - } else { - input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2])); - input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4])); - input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); - } - - /* process general packets */ - wacom_intuos_general(wacom); /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */ if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) { @@ -1036,7 +1002,44 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) input_report_key(input, wacom->tool[idx], 1); input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); wacom->reporting_data = true; - return 1; + return 2; +} + +static int wacom_intuos_irq(struct wacom_wac *wacom) +{ + unsigned char *data = wacom->data; + struct input_dev *input = wacom->pen_input; + int result; + + if (data[0] != WACOM_REPORT_PENABLED && + data[0] != WACOM_REPORT_INTUOSREAD && + data[0] != WACOM_REPORT_INTUOSWRITE && + data[0] != WACOM_REPORT_INTUOSPAD && + data[0] != WACOM_REPORT_INTUOS_PEN && + data[0] != WACOM_REPORT_CINTIQ && + data[0] != WACOM_REPORT_CINTIQPAD && + data[0] != WACOM_REPORT_INTUOS5PAD) { + dev_dbg(input->dev.parent, + "%s: received unknown report #%d\n", __func__, data[0]); + return 0; + } + + /* process pad events */ + result = wacom_intuos_pad(wacom); + if (result) + return result; + + /* process in/out prox events */ + result = wacom_intuos_inout(wacom); + if (result) + return result - 1; + + /* process general packets */ + result = wacom_intuos_general(wacom); + if (result) + return result - 1; + + return 0; } static int int_dist(int x1, int y1, int x2, int y2)