From patchwork Mon May 21 17:39:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kiryanov X-Patchwork-Id: 10416125 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 35CC8600CC for ; Mon, 21 May 2018 17:41:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25B612899F for ; Mon, 21 May 2018 17:41:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A4AB289A1; Mon, 21 May 2018 17:41:47 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, MAILING_LIST_MULTI, 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 A99CE2899F for ; Mon, 21 May 2018 17:41:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753399AbeEURll (ORCPT ); Mon, 21 May 2018 13:41:41 -0400 Received: from mail-qk0-f201.google.com ([209.85.220.201]:48463 "EHLO mail-qk0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753378AbeEURkW (ORCPT ); Mon, 21 May 2018 13:40:22 -0400 Received: by mail-qk0-f201.google.com with SMTP id y62-v6so16119173qkb.15 for ; Mon, 21 May 2018 10:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:message-id:subject:from:to:cc; bh=XVZwDk3+61unCUhUbHBmJHAny4ODdenvdler3VwgfSY=; b=K0NXdAMTAByCeZQEtXr9Ay75+mVsCqVZbXRZQNjXpv2kQipJU0TmE5ccrTPxEx6u/4 +HIydHc/68Fku35U83gp8uXWCajOQi6aah+5JfMOE7lcQo/qiLSpZfStxJ15L3dKG9cR 3OyyTdVvKAZntjC0SlrdqKA8+nXJ52Pc7VFYGXyoj9yIv8Vc/O30rD7uxUzmKdmMUhyW U1p73Mw0iTB2IrYNVwd+ENBu+0k8jGnpTwYUaYNITIsWIF7WP/aeokiJ8eqXDh8Zi831 KRbU46NUxqnA2Fi558nUyZHDZmBQG516UfRhmBllWUXLJwo+pm9oM7BqHzBsEmklYI2n btaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=XVZwDk3+61unCUhUbHBmJHAny4ODdenvdler3VwgfSY=; b=d9rVMIIImyUUbIRmDP7ie2x9ff92BqLrFUKDNEftkEjCq3Ztehoc3gyvUgsPWyHc2y Y+yHa8440EAL1Q7OPnOTYg0yvfe4555/eokl/OIXwxq/FTnn4ygnqRkMKABorHL0QkU2 fc9iDYMkLarY3wA0K6ku94z0EfLtr8jZiprlRcXMeSrsXjEzeCJvG/t4n8V3pg6RKCkh LE4j6PDbGjLVSeRiOTcp4D5L86nbdbhWd0AUzpK2j4s8I4iTDz6AwkLTThVs+i4SxMzA g++36ValJdaRrJhrJeab7+uAwCTGJahDoapLzE3kPt3qFYQrT12LYWLJPgY5dL5AJnr1 NnCg== X-Gm-Message-State: ALKqPwdDJirmtcPaY5/YFovWjrjMbtxKhWjo1XGEB2IRPAFdhgsJe4/b bfWC/CvWj/8rOXMxUw1WayHZcpZwT3XVFtXAKoT7LapNZtPKGeo7Y73ASYRyZ0568KJJeJacF0n eHDISecLREaBZRxt+mucE3YZHJYKdkeec8Bm0Haqr91/kd5fBVxx/WsN0mHzcIA4= X-Google-Smtp-Source: AB8JxZoHX6fh+5UMNHF8Do4pSei9DMKeXXQadK2v/wxW/jB+fu4jOrexbYOR5NvOINcrPLRE1HBqB6yE MIME-Version: 1.0 X-Received: by 2002:a0c:f946:: with SMTP id i6-v6mr13215740qvo.4.1526924421895; Mon, 21 May 2018 10:40:21 -0700 (PDT) Date: Mon, 21 May 2018 10:39:57 -0700 Message-Id: <20180521173957.140020-1-rkir@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog Subject: [PATCH] goldfish_events: no extra EV_SYN; register goldfish From: rkir@google.com To: linux-input@vger.kernel.org, tkjos@google.com, lfy@google.com, rkir@google.com Cc: tkjos@google.com, Lingfeng Yang , Roman Kiryanov 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 From: Lingfeng Yang If we send SYN_REPORT on every single multitouch event, it breaks the multitouch. The multitouch becomes janky and having to click 2-3 times to do stuff (plus randomly activating notification bars when not clicking) If we suppress these SYN_REPORTS, multitouch will work fine, plus the events will have a protocol that looks nice. In addition, we need to register Goldfish Events as a multitouch device by issuing input_mt_init_slots, otherwise input_handle_abs_event in drivers/input/input.c will silently drop all ABS_MT_SLOT events, making it so that touches with more than 1 finger do not work properly. Signed-off-by: "Lingfeng Yang" Signed-off-by: Roman Kiryanov --- drivers/input/keyboard/goldfish_events.c | 28 +++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/input/keyboard/goldfish_events.c b/drivers/input/keyboard/goldfish_events.c index e8dae6195b30..055accfeb0dd 100644 --- a/drivers/input/keyboard/goldfish_events.c +++ b/drivers/input/keyboard/goldfish_events.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,8 @@ #include #include +#define GOLDFISH_MAX_FINGERS 5 + enum { REG_READ = 0x00, REG_SET_PAGE = 0x00, @@ -52,7 +55,21 @@ static irqreturn_t events_interrupt(int irq, void *dev_id) value = __raw_readl(edev->addr + REG_READ); input_event(edev->input, type, code, value); - input_sync(edev->input); + // Send an extra (EV_SYN, SYN_REPORT, 0x0) event + // if a key was pressed. Some keyboard device + // drivers may only send the EV_KEY event and + // not EV_SYN. + // Note that sending an extra SYN_REPORT is not + // necessary nor correct protocol with other + // devices such as touchscreens, which will send + // their own SYN_REPORT's when sufficient event + // information has been collected (e.g., for + // touchscreens, when pressure and X/Y coordinates + // have been received). Hence, we will only send + // this extra SYN_REPORT if type == EV_KEY. + if (type == EV_KEY) + input_sync(edev->input); + return IRQ_HANDLED; } @@ -155,6 +172,15 @@ static int events_probe(struct platform_device *pdev) input_dev->name = edev->name; input_dev->id.bustype = BUS_HOST; + // Set the Goldfish Device to be multi-touch. + // In the Ranchu kernel, there is multi-touch-specific + // code for handling ABS_MT_SLOT events. + // See drivers/input/input.c:input_handle_abs_event. + // If we do not issue input_mt_init_slots, + // the kernel will filter out needed ABS_MT_SLOT + // events when we touch the screen in more than one place, + // preventing multi-touch with more than one finger from working. + input_mt_init_slots(input_dev, GOLDFISH_MAX_FINGERS, 0); events_import_bits(edev, input_dev->evbit, EV_SYN, EV_MAX); events_import_bits(edev, input_dev->keybit, EV_KEY, KEY_MAX);