From patchwork Thu May 31 23:37:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kiryanov X-Patchwork-Id: 10442135 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 D4BD6604D4 for ; Thu, 31 May 2018 23:37:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC34928E5F for ; Thu, 31 May 2018 23:37:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C08D028E6E; Thu, 31 May 2018 23:37:39 +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 32E5F28EB1 for ; Thu, 31 May 2018 23:37:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750872AbeEaXhe (ORCPT ); Thu, 31 May 2018 19:37:34 -0400 Received: from mail-it0-f74.google.com ([209.85.214.74]:41404 "EHLO mail-it0-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750842AbeEaXha (ORCPT ); Thu, 31 May 2018 19:37:30 -0400 Received: by mail-it0-f74.google.com with SMTP id m12-v6so19452868ita.6 for ; Thu, 31 May 2018 16:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:in-reply-to:message-id:references:subject:from:to :cc; bh=a54lMB9m1VUrxovpYvE4OvUzf9UdF3UzZG3o+nebfVQ=; b=DyUj53R5L4oX2gnnsCRtqmo7FZXSHSHxiLbJToa36Rx9ixUVlAKjTlEWUU/KTIJwhG hmgZ6sTy24M5SvR1qBXWvEumZWXPcdokwQz2Mhk/KGGesEinEGQaWFi6sl5kCfMFHNm4 Aj+8DGnHao51O346bwBGg+zwSVrxba61bHUh4ancoVJ5aIAg+JZEdmd1u2iUmNO5fUcK uqMtznIoJfUja+XpUJK5jgZGQvaTTChpZxT2HJ9zcjlwp1Dz+y2RVsbve4ShaBGZE7k8 xLpFyy2yrU9OAHUsDMHm1eMzpJGVRg4ymRNtGa28VqHOlc3Q79mHITViIWAWa5iQJz0M eHFA== 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:in-reply-to:message-id :references:subject:from:to:cc; bh=a54lMB9m1VUrxovpYvE4OvUzf9UdF3UzZG3o+nebfVQ=; b=bMxCEK11Sa1FbSDoZe6nNOzccO/RDfac149NL1ZjMQDRPCa41CWCbKNpNn3l9d4yaT DAc6BTIDiqEHcOHZQRTfCUwmp49EEX9qqJ4HBKfXI0rIE1tmnj5f1cCOEZncs5iKQTSV 3tRaAHoL0fnCauPM0JhyGG0MUIY/19+Xf4Faftr0aKdg6WP5L1U1ARKdNq1UAiZWbvs3 omGxZ3P74R+kp4vUsLMaH5xiWv8j7CuoQEX8D2s/vw6m1yqsJPz9i+0g+3ngpZBVKBKa 5KgHuxHZn3GBn6AERM+xJliV5kWnD+SxEelzPraHr7oUY+B2coaIhhwjpbQMvMLdkFS6 /3dw== X-Gm-Message-State: ALKqPwcy4XLsU7lnwbTAXCg7XnKP0N5Qq9fxAZFpordxkhBM2ba+Mcw4 QJZEbM77CbZtK6voc4n/aBsUcg7u X-Google-Smtp-Source: ADUXVKKHKQDH+6xJSla8jfv0EiXLD8lbBI8lG0c/+xcHgycaJaORKyecUtphcfX3pUv1v5FP1ZE4GpNX MIME-Version: 1.0 X-Received: by 2002:a24:b349:: with SMTP id z9-v6mr3913219iti.20.1527809850040; Thu, 31 May 2018 16:37:30 -0700 (PDT) Date: Thu, 31 May 2018 16:37:07 -0700 In-Reply-To: <20180531233707.80702-1-rkir@google.com> Message-Id: <20180531233707.80702-2-rkir@google.com> References: <20180531233707.80702-1-rkir@google.com> X-Mailer: git-send-email 2.17.0.921.gf22659ad46-goog Subject: [PATCH 2/2] goldfish_events: no extra EV_SYN; register goldfish From: rkir@google.com To: rydberg@bitmath.org Cc: linux-input@vger.kernel.org, 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);