From patchwork Tue Dec 1 01:13:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gerecke X-Patchwork-Id: 7731741 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 2F372BEEE5 for ; Tue, 1 Dec 2015 01:14:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2354820650 for ; Tue, 1 Dec 2015 01:14:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0CA482064D for ; Tue, 1 Dec 2015 01:14:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754474AbbLABN7 (ORCPT ); Mon, 30 Nov 2015 20:13:59 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:34916 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754488AbbLABN7 (ORCPT ); Mon, 30 Nov 2015 20:13:59 -0500 Received: by pacej9 with SMTP id ej9so202496674pac.2 for ; Mon, 30 Nov 2015 17:13:58 -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=thYSUriTTCY9V9VPnwKLG+eZzZge8LDPKJnlFjbRYjc=; b=IUzSQ8yoWBKDBrm8Eb5+9ptGpiWzZDavSzgJ4oT79/nKKyle1PLA8Tknde5g/6Q0Cg LJ4QbQy3l6ZELU+UhvlVtloqMrqigRo5Yw0KM1v7ZNlzsW3GYHhJlE4LyfSb+zB4Jbex lX9HzH3Hr5ec6PkpUFsfTpgJy+kva6cvvilqMTdfjZ6oR4cAs/K7E+WsSxEpchiW74HQ tC2FMgEDHvU0YKgLUSfmr7wmrOzqbQLqDXO+6VToqfpX/lIsLjCNpyR6opK0GqL6P+a/ GonJq4uCNQbJ9YuHae58Z5EDuGkLKjUt3s6DpYrvKC0JO4LQT0Lv1pS0f62Z0XsCSnBp ACbQ== X-Received: by 10.98.10.2 with SMTP id s2mr75094315pfi.45.1448932438542; Mon, 30 Nov 2015 17:13:58 -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.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Nov 2015 17:13:57 -0800 (PST) From: Jason Gerecke To: linux-input@vger.kernel.org Cc: Jiri Kosina , Ping Cheng , Aaron Skomra , Jason Gerecke , Jason Gerecke Subject: [PATCH 5/7] HID: wacom: Further clean up wacom_intuos_general packet decoder Date: Mon, 30 Nov 2015 17:13:50 -0800 Message-Id: <1448932432-10115-5-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 re-organizing and trimming cases to make it easier to wrap the brain around. A number of changes were made after consulting the protocol spec and so don't necessarily follow from the code itself. Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 87 +++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 46 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index a426cb2..ce3afab 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -925,7 +925,6 @@ static int wacom_intuos_general(struct wacom_wac *wacom) break; case 0x0a: - case 0x0b: /* airbrush second packet */ input_report_abs(input, ABS_WHEEL, (data[6] << 2) | ((data[7] >> 6) & 3)); @@ -935,7 +934,6 @@ static int wacom_intuos_general(struct wacom_wac *wacom) break; case 0x05: - case 0x07: /* Rotation packet */ if (features->type >= INTUOS3S) { /* I3 marker pen rotation */ @@ -944,61 +942,56 @@ static int wacom_intuos_general(struct wacom_wac *wacom) ((t-1) / 2 + 450)) : (450 - t / 2) ; input_report_abs(input, ABS_Z, t); } else { - /* 4D mouse rotation packet */ + /* 4D mouse 2nd packet */ t = (data[6] << 3) | ((data[7] >> 5) & 7); input_report_abs(input, ABS_RZ, (data[7] & 0x20) ? ((t - 1) / 2) : -t / 2); } break; - /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */ case 0x04: + /* 4D mouse 1st packet */ + input_report_key(input, BTN_LEFT, data[8] & 0x01); + input_report_key(input, BTN_MIDDLE, data[8] & 0x02); + input_report_key(input, BTN_RIGHT, data[8] & 0x04); + + input_report_key(input, BTN_SIDE, data[8] & 0x20); + input_report_key(input, BTN_EXTRA, data[8] & 0x10); + t = (data[6] << 2) | ((data[7] >> 6) & 3); + input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); + break; + case 0x06: - case 0x08: - if (features->type < INTUOS3S && type != 0x08) { - /* 4D mouse packet */ - input_report_key(input, BTN_LEFT, data[8] & 0x01); - input_report_key(input, BTN_MIDDLE, data[8] & 0x02); - input_report_key(input, BTN_RIGHT, data[8] & 0x04); + /* I4 mouse */ + input_report_key(input, BTN_LEFT, data[6] & 0x01); + input_report_key(input, BTN_MIDDLE, data[6] & 0x02); + input_report_key(input, BTN_RIGHT, data[6] & 0x04); + input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7) + - ((data[7] & 0x40) >> 6)); + input_report_key(input, BTN_SIDE, data[6] & 0x08); + input_report_key(input, BTN_EXTRA, data[6] & 0x10); - input_report_key(input, BTN_SIDE, data[8] & 0x20); - input_report_key(input, BTN_EXTRA, data[8] & 0x10); - t = (data[6] << 2) | ((data[7] >> 6) & 3); - input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); - } - else if (wacom->tool[idx] == BTN_TOOL_MOUSE) { - /* I4 mouse */ - if (features->type >= INTUOS4S && features->type <= INTUOSPL) { - input_report_key(input, BTN_LEFT, data[6] & 0x01); - input_report_key(input, BTN_MIDDLE, data[6] & 0x02); - input_report_key(input, BTN_RIGHT, data[6] & 0x04); - input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7) - - ((data[7] & 0x40) >> 6)); - input_report_key(input, BTN_SIDE, data[6] & 0x08); - input_report_key(input, BTN_EXTRA, data[6] & 0x10); - - input_report_abs(input, ABS_TILT_X, - (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); - input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); - } else { - /* 2D mouse packet */ - input_report_key(input, BTN_LEFT, data[8] & 0x04); - input_report_key(input, BTN_MIDDLE, data[8] & 0x08); - input_report_key(input, BTN_RIGHT, data[8] & 0x10); - input_report_rel(input, REL_WHEEL, (data[8] & 0x01) - - ((data[8] & 0x02) >> 1)); - - /* I3 2D mouse side buttons */ - if (features->type >= INTUOS3S && features->type <= INTUOS3L) { - input_report_key(input, BTN_SIDE, data[8] & 0x40); - input_report_key(input, BTN_EXTRA, data[8] & 0x20); - } + input_report_abs(input, ABS_TILT_X, + (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); + input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); + break; + + case 0x08: + if (wacom->tool[idx] == BTN_TOOL_MOUSE) { + /* 2D mouse packet */ + input_report_key(input, BTN_LEFT, data[8] & 0x04); + input_report_key(input, BTN_MIDDLE, data[8] & 0x08); + input_report_key(input, BTN_RIGHT, data[8] & 0x10); + input_report_rel(input, REL_WHEEL, (data[8] & 0x01) + - ((data[8] & 0x02) >> 1)); + + /* I3 2D mouse side buttons */ + if (features->type >= INTUOS3S && features->type <= INTUOS3L) { + input_report_key(input, BTN_SIDE, data[8] & 0x40); + input_report_key(input, BTN_EXTRA, data[8] & 0x20); } } - else if ((features->type < INTUOS3S || features->type == INTUOS3L || - features->type == INTUOS4L || features->type == INTUOS5L || - features->type == INTUOSPL) && - wacom->tool[idx] == BTN_TOOL_LENS) { + else if (wacom->tool[idx] == BTN_TOOL_LENS) { /* Lens cursor packets */ input_report_key(input, BTN_LEFT, data[8] & 0x01); input_report_key(input, BTN_MIDDLE, data[8] & 0x02); @@ -1008,7 +1001,9 @@ static int wacom_intuos_general(struct wacom_wac *wacom) } break; + case 0x07: case 0x09: + case 0x0b: case 0x0c: case 0x0d: case 0x0e: