Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7280339imu; Wed, 14 Nov 2018 14:47:19 -0800 (PST) X-Google-Smtp-Source: AJdET5dK/bK9is4eH9aMBbCWQnGZfMnpH2FMB9DzCTntaLkEO3RHaCsoUz7jHqE9eJfL+vOBeUlt X-Received: by 2002:a17:902:bd92:: with SMTP id q18mr3763898pls.167.1542235639337; Wed, 14 Nov 2018 14:47:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542235639; cv=none; d=google.com; s=arc-20160816; b=A3NfmQctwh34nbIcy4Cs/K6WjAux26ZCIc4r1yZBvsXzUW4MnCtiG/anBYLP2gb1h0 8DEVF58cGoIhola1GGHGW327ExcWEmWuqE6R/dznZoOIJO4Rv4jnk7BHjuI9ERlZCPbF DNuHc0Om3NdI5cuSao5fJxuT5dWmAxZXJgOzrIqoAvCUUngP6vPvPIEbIzgSAmlj7ul/ Ef+gmTDFh7jIzPh5MWNZ2eghpU48n6KBi3+8W+Qm7D6u1kIswyXTWF7GlcU7pX3bIkBz 9wjB8+wAeoi7ut3grxPEgFyCRXPNi6Fe+nrYrU+mulVr+UiDss399QIIgw/5hcTczwcV E29w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=IOBuVIIt9LvYmhGUdgIzbs3LpWdWB9k++pvlkJnMMDQ=; b=vN0MbuxldiNDApvKLCMoHRokJBG9Z8KYFHpDl7g2cEfNiYu+rSWDbEWMKwYT21Z658 CZ6gGoclbqoYLReqTClS5aS/gKgDDEuPm1bilJckgPPYMLqxX5+1qazNQofkiCranrYc psUaXC4xUeix/2FUlv7FBO/Oj9TEBpCus6aQl5Jl20dEe94lJgOxQmwe/71v2nWJZjwC UEeJm7lZqCO1bMiU+jLz71Dy2yXv8mtSK9GU1Ts5tn9tuC/su3eS+HeH7w9DUpZ7B3KK MMFk13F5ANWQPyjctYl6Ps5FNDBOJwgExbWI1zPG2f9nLuOoG9CsbyX/UpFa17TxgKJq aKOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vgjMViOr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a93-v6si29502321pla.226.2018.11.14.14.47.04; Wed, 14 Nov 2018 14:47:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vgjMViOr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727086AbeKOI1O (ORCPT + 99 others); Thu, 15 Nov 2018 03:27:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:34408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726892AbeKOI1N (ORCPT ); Thu, 15 Nov 2018 03:27:13 -0500 Received: from sasha-vm.mshome.net (unknown [64.114.255.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CD1952251B; Wed, 14 Nov 2018 22:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542234129; bh=Q92eScgjO+TudlWLKcxr/BkUUBMXqfbVXj7HzBEOX+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vgjMViOrlOWEJDoEjfOaYhFjwVjxfnvm8HTOebFCVVVwp1tR0mkCB2Wj/rfwIhBzw 3ISNeQryCNBxReDobCpFMnx4fsVhqkY/48J8z8jmSa5LjnwMoVvISZVSwpheIvWiGC 0qg7X+a0APv7tGfF2pfCvnHwwnWc/oe99SZZ1W+s= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kai-Heng Feng , Jiri Kosina , Sasha Levin Subject: [PATCH AUTOSEL 4.19 06/73] HID: i2c-hid: Add a small delay after sleep command for Raydium touchpanel Date: Wed, 14 Nov 2018 17:21:00 -0500 Message-Id: <20181114222207.98701-6-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181114222207.98701-1-sashal@kernel.org> References: <20181114222207.98701-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kai-Heng Feng [ Upstream commit 00b790ea545b6ef30221adef6e9c3707e03b82b5 ] Raydium touchpanel (2386:4B33) sometimes does not work in desktop session although it works in display manager. During user logging, the display manager exits, close the HID device, then the device gets runtime suspended and powered off. The desktop session begins shortly after, opens the HID device, then the device gets runtime resumed and powered on. If the trasition from display manager to desktop sesesion is fast, the touchpanel cannot switch from powered off to powered on in short timeframe. So add a small delay to workaround the issue. Signed-off-by: Kai-Heng Feng Reviewed-by: Benjamin Tissoires Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-ids.h | 3 +++ drivers/hid/i2c-hid/i2c-hid.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index bc49909aba8e..636b9d903b26 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -921,6 +921,9 @@ #define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3003 0x3003 #define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008 0x3008 +#define I2C_VENDOR_ID_RAYDIUM 0x2386 +#define I2C_PRODUCT_ID_RAYDIUM_4B33 0x4b33 + #define USB_VENDOR_ID_RAZER 0x1532 #define USB_DEVICE_ID_RAZER_BLADE_14 0x011D diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 4e3592e7a3f7..88daa388e1f6 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -48,6 +48,7 @@ #define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV BIT(0) #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1) #define I2C_HID_QUIRK_NO_RUNTIME_PM BIT(2) +#define I2C_HID_QUIRK_DELAY_AFTER_SLEEP BIT(3) /* flags */ #define I2C_HID_STARTED 0 @@ -157,6 +158,8 @@ struct i2c_hid { bool irq_wake_enabled; struct mutex reset_lock; + + unsigned long sleep_delay; }; static const struct i2c_hid_quirks { @@ -171,6 +174,8 @@ static const struct i2c_hid_quirks { { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, I2C_HID_QUIRK_NO_IRQ_AFTER_RESET | I2C_HID_QUIRK_NO_RUNTIME_PM }, + { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_4B33, + I2C_HID_QUIRK_DELAY_AFTER_SLEEP }, { 0, 0 } }; @@ -386,6 +391,7 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state) { struct i2c_hid *ihid = i2c_get_clientdata(client); int ret; + unsigned long now, delay; i2c_hid_dbg(ihid, "%s\n", __func__); @@ -403,9 +409,22 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state) goto set_pwr_exit; } + if (ihid->quirks & I2C_HID_QUIRK_DELAY_AFTER_SLEEP && + power_state == I2C_HID_PWR_ON) { + now = jiffies; + if (time_after(ihid->sleep_delay, now)) { + delay = jiffies_to_usecs(ihid->sleep_delay - now); + usleep_range(delay, delay + 1); + } + } + ret = __i2c_hid_command(client, &hid_set_power_cmd, power_state, 0, NULL, 0, NULL, 0); + if (ihid->quirks & I2C_HID_QUIRK_DELAY_AFTER_SLEEP && + power_state == I2C_HID_PWR_SLEEP) + ihid->sleep_delay = jiffies + msecs_to_jiffies(20); + if (ret) dev_err(&client->dev, "failed to change power setting.\n"); -- 2.17.1