From patchwork Thu Nov 24 14:25:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Donohue X-Patchwork-Id: 9445553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4903C60779 for ; Thu, 24 Nov 2016 14:26:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F4D627F7F for ; Thu, 24 Nov 2016 14:26:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 343A327FA7; Thu, 24 Nov 2016 14:26:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4B7527FA4 for ; Thu, 24 Nov 2016 14:26:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965482AbcKXO0d (ORCPT ); Thu, 24 Nov 2016 09:26:33 -0500 Received: from Lepton.TopQuark.net ([168.235.66.66]:40457 "EHLO Mail2.TopQuark.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965566AbcKXO0d (ORCPT ); Thu, 24 Nov 2016 09:26:33 -0500 Received: from Mail1.TopQuark.net (pool-108-48-201-133.washdc.fios.verizon.net [108.48.201.133]) by Mail2.TopQuark.net (Postfix) with ESMTP id BFF97F60474; Thu, 24 Nov 2016 09:26:31 -0500 (EST) Received: from Mail1.TopQuark.net (unknown [127.0.0.1]) by Mail1.TopQuark.net (Postfix) with ESMTP id 21AB927EE376; Thu, 24 Nov 2016 09:26:30 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=PaulSD.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=mail; bh=QP1VhA9/s5vs SuBYgfisHXqtxyU=; b=Nn9NJ65wknty/c9iYHjzWoa0C1+2NMqnlCbD6SuFKBzc hJEz+bqaa+OmgCUNh65DG9Mo/Mqq3cDqJmDn6o3ZUvzC70HQSrhpDRbTaxHGq8N/ AkZ88GVflIK/lykJ8yAyptW9aI/Qn4vLJyoSaIbckVMTz0O8tFD7DW+48IE6E6g= Received: by Mail1.TopQuark.net (Postfix, from userid 1000) id 4087B27EE2B2; Thu, 24 Nov 2016 09:26:28 -0500 (EST) From: Paul Donohue To: linux-input@vger.kernel.org Cc: Ben Gamari , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Michal Hocko , Paul Donohue Subject: [PATCH v6 2/3] Input: ALPS - Clean up TrackStick handling for SS5 hardware Date: Thu, 24 Nov 2016 09:25:52 -0500 Message-Id: <1479997553-25877-3-git-send-email-linux-kernel@PaulSD.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479997553-25877-1-git-send-email-linux-kernel@PaulSD.com> References: <201611111459.12642@pali> <1479997553-25877-1-git-send-email-linux-kernel@PaulSD.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For consistency and clarity, the input_report_*() functions should be called by alps_process_packet_ss4_v2() instead of by alps_decode_ss4_v2(). Reviewed-by: Pali Rohár Signed-off-by: Paul Donohue --- drivers/input/mouse/alps.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index b93fe83..61d61cc 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -1267,18 +1267,12 @@ static int alps_decode_ss4_v2(struct alps_fields *f, break; case SS4_PACKET_ID_STICK: - if (!(priv->flags & ALPS_DUALPOINT)) { - psmouse_warn(psmouse, - "Rejected trackstick packet from non DualPoint device"); - } else { - int x = (s8)(((p[0] & 1) << 7) | (p[1] & 0x7f)); - int y = (s8)(((p[3] & 1) << 7) | (p[2] & 0x7f)); - int pressure = (s8)(p[4] & 0x7f); - - input_report_rel(priv->dev2, REL_X, x); - input_report_rel(priv->dev2, REL_Y, -y); - input_report_abs(priv->dev2, ABS_PRESSURE, pressure); - } + /* + * x, y, and pressure are decoded in + * alps_process_packet_ss4_v2() + */ + f->first_mp = 0; + f->is_mp = 0; break; case SS4_PACKET_ID_IDLE: @@ -1312,6 +1306,7 @@ static void alps_process_packet_ss4_v2(struct psmouse *psmouse) struct input_dev *dev = psmouse->dev; struct input_dev *dev2 = priv->dev2; struct alps_fields *f = &priv->f; + int x, y, pressure; memset(f, 0, sizeof(struct alps_fields)); priv->decode_fields(f, packet, psmouse); @@ -1348,12 +1343,25 @@ static void alps_process_packet_ss4_v2(struct psmouse *psmouse) /* Report trackstick */ if (alps_get_pkt_id_ss4_v2(packet) == SS4_PACKET_ID_STICK) { - if (priv->flags & ALPS_DUALPOINT) { - input_report_key(dev2, BTN_LEFT, f->ts_left); - input_report_key(dev2, BTN_RIGHT, f->ts_right); - input_report_key(dev2, BTN_MIDDLE, f->ts_middle); - input_sync(dev2); + if (!(priv->flags & ALPS_DUALPOINT)) { + psmouse_warn(psmouse, + "Rejected trackstick packet from non DualPoint device"); + return; } + + x = (s8)(((packet[0] & 1) << 7) | (packet[1] & 0x7f)); + y = (s8)(((packet[3] & 1) << 7) | (packet[2] & 0x7f)); + pressure = (s8)(packet[4] & 0x7f); + + input_report_rel(dev2, REL_X, x); + input_report_rel(dev2, REL_Y, -y); + input_report_abs(dev2, ABS_PRESSURE, pressure); + + input_report_key(dev2, BTN_LEFT, f->ts_left); + input_report_key(dev2, BTN_RIGHT, f->ts_right); + input_report_key(dev2, BTN_MIDDLE, f->ts_middle); + + input_sync(dev2); return; }