From patchwork Fri Nov 18 17:02:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 22398 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp312075wrr; Fri, 18 Nov 2022 09:13:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf4B6Xt/er8SN3G8kIdh9TUwgcuObx/8wuOwplr8cc1rtz5ZiC0iA6lzguSjHHrINwvHGWlq X-Received: by 2002:a17:906:43d0:b0:78d:a01b:b474 with SMTP id j16-20020a17090643d000b0078da01bb474mr6886390ejn.8.1668791598231; Fri, 18 Nov 2022 09:13:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668791598; cv=none; d=google.com; s=arc-20160816; b=RFQAYWrIkFTOD8nq4EcErKU4z2OCrkPzXmQ4SdE4mtJQQJhmkx30Nkr6Ex6eehPoDF DKyWFUtjUji5SEp14JmQSm/4vRuaa1Mrg+XIy80czk5hBxlZzZ4sZuKpiIWPMgb/D3Gd XFNEY5cRQ+S4urmcLgTidOWFctQuzu0isa1qGAzAlRIfmzytxjf47kqlbZ+V3abKbRk2 qi2sduuTKQeGvjNK1a0gAtCBWfHSoCw5dmh0bwxrRI4NSM4dQZC/yRuuO6Oy4/ZI8Ek5 P7nk/ZSSjbA+9nSiBZbXUledhFzfpJoM76WESwQ01ynXrrOEFAuZ8iBHT1nf27/JM7G8 S5Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=sLTJOW58qEMnvyde+G1ONR5iNscDQCTf/dCwM8qW96w=; b=rxhiJuuSVttnvpHREsA9I5U0KOr5Ed1U8Q0oRJaGLrHZ9fPUDfmn5ntg9E2Aer6DcU RFvg/g/p//V7efJk3lAIsjTAPRJVwmsYmSkYzCNgrOeDMCxRvTvgW3ttVSH+q5c+kj99 BZ2pfQ2momZ1Ltl3CHnogswB9Mvd5l30jSZPDx4A/zVEIzGZrV/Jlpx85l7GanYUGjVJ QuCjtXkddLB40PUQ3ctlMohZC/nKv0W2LsJnUSDF5kxwqOSB8JpTQjPlsPqRRd7g1MUT txoA9VnN9KumpLPommwyr8q5jtOO9TRkf1jsAU0nOJLNsipFoVzgYRa2KEzf2lRT/peE qV3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aMrvoD24; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs31-20020a1709073e9f00b0078e27ef9501si3171962ejc.750.2022.11.18.09.12.44; Fri, 18 Nov 2022 09:13:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aMrvoD24; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242417AbiKRRDJ (ORCPT + 99 others); Fri, 18 Nov 2022 12:03:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234447AbiKRRCw (ORCPT ); Fri, 18 Nov 2022 12:02:52 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79CFD87564; Fri, 18 Nov 2022 09:02:50 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id m14so5048516pji.0; Fri, 18 Nov 2022 09:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=sLTJOW58qEMnvyde+G1ONR5iNscDQCTf/dCwM8qW96w=; b=aMrvoD24ysb6PngqTRy1y2/b3jLGiR6TwNcfW9xWdTUun7eKRtSgLMKFlvIrj4CZ6g nIWu/5ayN+Kf0NQToVu3F3MsXnUiO6TK5HywiPwhqFvJiTiXZrr5uT7BNMjQRl3nGfFV KrIYi9mQcwDHyT9roApDtCdKQYxIBd6RDAe55uD5Kg9J6R0bNMXvOZK1Cx+8l6hF+6sF /A/68aSNJdvFxfsjlIXETo+boV9LyI9skmoxeirjOMv6AlRCx7si9RJgtlfP08KudvKN 19THyTepXmQmmsyGbs4FAQnt8kJxtblNJo97JqLI1PNi3K+I44egs8vL2U9D7xjVBF5j 7jsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sLTJOW58qEMnvyde+G1ONR5iNscDQCTf/dCwM8qW96w=; b=PAar0inn/bmdVhCPHBPu+T4YWkbs3Trkk4EV8hAkv03tCJPO6Mv+cy6X2D/niEMXcO 3vOZlpQbnDtmlgtBbCMg8AL6FHhqj46d7P7ZVYZSs5SJuGrI7kHGgPvszUzLllLn8kZX eC5z5RNHfhXVysEsT8gLR/CX8cwWzBcf7MPdIiUU2Tb527EZm1uetwuO+BvpVER5kGj8 R2PYdATY4Wsv3JKso1kn7StaEXvXlNUSECNKG+5twyfqlx5plrqY75cjQDH0OQMf0mtk GvgWVNQKbpKCx64NTqOVupcm2NDhszCkbIvNrX6tYPcwzKIzlgbw2MZk++FlzxXgj9Pv Sjxw== X-Gm-Message-State: ANoB5pm6zcMFm+cnIyRZm41YWxwp+JTOmAhCwWxzoDVftODokSWq4aF7 x00LY4cQJoOmwh2BzgBagYA= X-Received: by 2002:a17:902:e492:b0:186:5f71:7939 with SMTP id i18-20020a170902e49200b001865f717939mr265130ple.162.1668790969817; Fri, 18 Nov 2022 09:02:49 -0800 (PST) Received: from google.com ([2620:15c:9d:2:e4c5:c31d:4c68:97a0]) by smtp.gmail.com with ESMTPSA id x7-20020a17090a788700b0020ad53b5883sm3047337pjk.14.2022.11.18.09.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 09:02:48 -0800 (PST) Date: Fri, 18 Nov 2022 09:02:45 -0800 From: Dmitry Torokhov To: Jiri Kosina , Benjamin Tissoires Cc: Marge Yang , Matthias Kaehlcke , Hans de Goede , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] hid: i2c: let RMI devices decide what constitutes wakeup event Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749854819126806723?= X-GMAIL-MSGID: =?utf-8?q?1749854819126806723?= HID-RMI is special in the sense that it does not carry HID events directly, but rather uses HID protocol as a wrapper/transport for RMI protocol. Therefore we should not assume that all data coming from the device via interrupt is associated with user activity and report wakeup event indiscriminately, but rather let HID-RMI do that when appropriate. HID-RMI devices tag responses to the commands issued by the host as RMI_READ_DATA_REPORT_ID whereas motion and other input events from the device are tagged as RMI_ATTN_REPORT_ID. Change hid-rmi to report wakeup events when receiving the latter packets. This allows ChromeOS to accurately identify wakeup source and make correct decision on the mode of the resume the system should take ("dark" where the display stays off vs normal one). Fixes: d951ae1ce803 ("HID: i2c-hid: Report wakeup events") Signed-off-by: Dmitry Torokhov --- drivers/hid/hid-rmi.c | 2 ++ drivers/hid/i2c-hid/i2c-hid-core.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c index bb1f423f4ace..84e7ba5314d3 100644 --- a/drivers/hid/hid-rmi.c +++ b/drivers/hid/hid-rmi.c @@ -326,6 +326,8 @@ static int rmi_input_event(struct hid_device *hdev, u8 *data, int size) if (!(test_bit(RMI_STARTED, &hdata->flags))) return 0; + pm_wakeup_event(hdev->dev.parent, 0); + local_irq_save(flags); rmi_set_attn_data(rmi_dev, data[1], &data[2], size - 2); diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index 0667b6022c3b..a9428b7f34a4 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -554,7 +554,8 @@ static void i2c_hid_get_input(struct i2c_hid *ihid) i2c_hid_dbg(ihid, "input: %*ph\n", ret_size, ihid->inbuf); if (test_bit(I2C_HID_STARTED, &ihid->flags)) { - pm_wakeup_event(&ihid->client->dev, 0); + if (ihid->hid->group != HID_GROUP_RMI) + pm_wakeup_event(&ihid->client->dev, 0); hid_input_report(ihid->hid, HID_INPUT_REPORT, ihid->inbuf + sizeof(__le16),