From patchwork Wed Feb 8 08:26:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9561957 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 9E78960236 for ; Wed, 8 Feb 2017 08:26:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 929C528411 for ; Wed, 8 Feb 2017 08:26:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85D9028467; Wed, 8 Feb 2017 08: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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 0408128411 for ; Wed, 8 Feb 2017 08:26:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932293AbdBHI0d (ORCPT ); Wed, 8 Feb 2017 03:26:33 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33817 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753813AbdBHI0c (ORCPT ); Wed, 8 Feb 2017 03:26:32 -0500 Received: by mail-pf0-f195.google.com with SMTP id y143so11183943pfb.1; Wed, 08 Feb 2017 00:26:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XY6vmWUvToudV6aj78kB5I+Evai5SfiM/bFVOklHAqc=; b=kNwco0nY7Cjz9PB3z8hBEdRp7Pk1GOcCrnsirWZmWhxoOiQCy2P4oDrcnl52jJMd3Y 7QZIqFgTtWOXM2g2MtWGgljZ1XGRiZBtCLWfUSd1PprDXLvAh29VKiF3pIFADtBJYpR8 cugdrMJ3d1cogaGYpohJkzTNX0nzHAUHKv7cBRkAlhVE2p5AHHksJsDY4Nsztsm3hY60 XTtaopnObk6w1C1qSdyAkh5QngVJZ9SYFfHKd/qUlvk+Gx/sEHiGDbJOJhVN+/qgdF6u Ky2czJXBKyGharHHi94eLQRFwr8vRBwI84PpsHqTB+kg2jZOh1FkS0ryFcE/zSQkufWh 6RPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XY6vmWUvToudV6aj78kB5I+Evai5SfiM/bFVOklHAqc=; b=kvPHEnrrBxp/qSsVjk3axVtqePaGM2KkI+BWyaJJcjUleATu8eZCgOUulCCLpqnPlv mlR/r7Uf7d4sjs5Q9Ny0OFgdXRohOWC+TfGmsX03tZPnS7fRSpv/DYFQ2SCUr5enEdMt 0erxGeUqC7vIUWEc93csazyJQi+i8LI6x6RgOkBCd1Djx/uft7JCGx/E+UvD8nlysdFg ag1rQKHlTq1k+O24jLIrb1ITpwvoNHUMt2L91/1Pf1BzGgEEeSif3h2oxzx84VxfR3zW hVN4FLdd9hL7K52OdVYm/YMPq0D32c5I5GKhpNccHoQIlDFPRg/AWW5yzvIdPphruWDR 6eyw== X-Gm-Message-State: AIkVDXI4Tcvr298rCBiP0FOQ6uR9S57aaHvJu3VvK0+jJqF+OpddHFqOoGN/1sjxDHEY9Q== X-Received: by 10.98.192.216 with SMTP id g85mr24656928pfk.117.1486542391874; Wed, 08 Feb 2017 00:26:31 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1311:a8eb:fb15:5bb6:95c8]) by smtp.gmail.com with ESMTPSA id f3sm17690380pga.34.2017.02.08.00.26.30 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 08 Feb 2017 00:26:31 -0800 (PST) Date: Wed, 8 Feb 2017 00:26:28 -0800 From: Dmitry Torokhov To: Benjamin Tissoires Cc: KT Liao , Andrew Duggan , Adrian Alves , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: Re: [PATCH v2 1/2] Input: psmouse - add a custom serio protocol to send extra information Message-ID: <20170208082628.GA9231@dtor-ws> References: <20170206192327.GA17441@dtor-ws> <20170207162539.5577-1-benjamin.tissoires@redhat.com> <20170207162539.5577-2-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170207162539.5577-2-benjamin.tissoires@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Tue, Feb 07, 2017 at 05:25:38PM +0100, Benjamin Tissoires wrote: > The tracksticks on the Lenovo thinkpads have their buttons connected > through the touchpad device. We already fixed that in synaptics.c, but > when we switch the device into RMI4 mode to have proper support, the > pass-through functionality can't deal with them easily. > > We add a new PS/2 flag and protocol designed for psmouse. > The RMI4 F03 pass-through can then emit a special set of commands > to notify psmouse the state of the buttons. > > This patch implements the protocol in psmouse, while an other will > do the same for rmi4-f03. > > Signed-off-by: Benjamin Tissoires Looks mostly good, but how about this one? Thanks. Tested-by: Benjamin Tissoires diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index bee267424972..98a34105d5b0 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -127,6 +127,13 @@ struct psmouse_protocol { int (*init)(struct psmouse *); }; +static void psmouse_report_standard_buttons(struct input_dev *dev, u8 buttons) +{ + input_report_key(dev, BTN_LEFT, buttons & BIT(0)); + input_report_key(dev, BTN_MIDDLE, buttons & BIT(2)); + input_report_key(dev, BTN_RIGHT, buttons & BIT(1)); +} + /* * psmouse_process_byte() analyzes the PS/2 data stream and reports * relevant events to the input module once full packet has arrived. @@ -199,9 +206,8 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse) } /* Generic PS/2 Mouse */ - input_report_key(dev, BTN_LEFT, packet[0] & 1); - input_report_key(dev, BTN_MIDDLE, (packet[0] >> 2) & 1); - input_report_key(dev, BTN_RIGHT, (packet[0] >> 1) & 1); + psmouse_report_standard_buttons(dev, + packet[0] | psmouse->extra_buttons); input_report_rel(dev, REL_X, packet[1] ? (int) packet[1] - (int) ((packet[0] << 4) & 0x100) : 0); input_report_rel(dev, REL_Y, packet[2] ? (int) ((packet[0] << 3) & 0x100) - (int) packet[2] : 0); @@ -282,6 +288,28 @@ static int psmouse_handle_byte(struct psmouse *psmouse) return 0; } +static void psmouse_handle_oob_data(struct psmouse *psmouse, u8 data) +{ + switch (psmouse->oob_data_type) { + case PSMOUSE_OOB_NONE: + psmouse->oob_data_type = data; + break; + + case PSMOUSE_OOB_EXTRA_BTNS: + psmouse_report_standard_buttons(psmouse->dev, data); + psmouse->extra_buttons = data; + psmouse->oob_data_type = PSMOUSE_OOB_NONE; + break; + + default: + psmouse_warn(psmouse, + "unknown OOB_DATA type: 0x%02x\n", + psmouse->oob_data_type); + psmouse->oob_data_type = PSMOUSE_OOB_NONE; + break; + } +} + /* * psmouse_interrupt() handles incoming characters, either passing them * for normal processing or gathering them as command response. @@ -306,6 +334,11 @@ static irqreturn_t psmouse_interrupt(struct serio *serio, goto out; } + if (flags & SERIO_OOB_DATA) { + psmouse_handle_oob_data(psmouse, data); + goto out; + } + if (unlikely(psmouse->ps2dev.flags & PS2_FLAG_ACK)) if (ps2_handle_ack(&psmouse->ps2dev, data)) goto out; diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index e0ca6cda3d16..8c83b8e2505c 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h @@ -1,6 +1,9 @@ #ifndef _PSMOUSE_H #define _PSMOUSE_H +#define PSMOUSE_OOB_NONE 0x00 +#define PSMOUSE_OOB_EXTRA_BTNS 0x01 + #define PSMOUSE_CMD_SETSCALE11 0x00e6 #define PSMOUSE_CMD_SETSCALE21 0x00e7 #define PSMOUSE_CMD_SETRES 0x10e8 @@ -53,6 +56,8 @@ struct psmouse { unsigned char pktcnt; unsigned char pktsize; unsigned char type; + unsigned char oob_data_type; + unsigned char extra_buttons; bool ignore_parity; bool acks_disable_command; unsigned int model; diff --git a/include/uapi/linux/serio.h b/include/uapi/linux/serio.h index f2447a83ac8d..ccd0ccd00f47 100644 --- a/include/uapi/linux/serio.h +++ b/include/uapi/linux/serio.h @@ -17,9 +17,10 @@ /* * bit masks for use in "interrupt" flags (3rd argument) */ -#define SERIO_TIMEOUT 1 -#define SERIO_PARITY 2 -#define SERIO_FRAME 4 +#define SERIO_TIMEOUT BIT(0) +#define SERIO_PARITY BIT(1) +#define SERIO_FRAME BIT(2) +#define SERIO_OOB_DATA BIT(3) /* * Serio types