From: Hans de Goede <hdegoede@redhat.com>
To: Jiaxun Yang <jiaxun.yang@flygoat.com>,
platform-driver-x86@vger.kernel.org
Cc: stable@vger.kernel.org, Ike Panhc <ike.pan@canonical.com>,
Mark Gross <mgross@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH fixes v3] platform/x86: ideapad-laptop: Disable touchpad_switch for ELAN0634
Date: Mon, 4 Jan 2021 12:26:07 +0100 [thread overview]
Message-ID: <60493709-e0f6-2079-7007-67e85445d2dc@redhat.com> (raw)
In-Reply-To: <20210103033651.47580-1-jiaxun.yang@flygoat.com>
Hi,
On 1/3/21 4:36 AM, Jiaxun Yang wrote:
> Newer ideapads (e.g.: Yoga 14s, 720S 14) come with ELAN0634 touchpad do not
> use EC to switch touchpad.
>
> Reading VPCCMD_R_TOUCHPAD will return zero thus touchpad may be blocked
> unexpectedly.
> Writing VPCCMD_W_TOUCHPAD may cause a spurious key press.
>
> Add has_touchpad_switch to workaround these machines.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: stable@vger.kernel.org # 5.4+
> --
> v2: Specify touchpad to ELAN0634
> v3: Stupid missing ! in v2
> ---
> drivers/platform/x86/ideapad-laptop.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
> index 7598cd46cf60..427970b3b0da 100644
> --- a/drivers/platform/x86/ideapad-laptop.c
> +++ b/drivers/platform/x86/ideapad-laptop.c
> @@ -92,6 +92,7 @@ struct ideapad_private {
> struct dentry *debug;
> unsigned long cfg;
> bool has_hw_rfkill_switch;
> + bool has_touchpad_switch;
> const char *fnesc_guid;
> };
>
> @@ -535,7 +536,9 @@ static umode_t ideapad_is_visible(struct kobject *kobj,
> } else if (attr == &dev_attr_fn_lock.attr) {
> supported = acpi_has_method(priv->adev->handle, "HALS") &&
> acpi_has_method(priv->adev->handle, "SALS");
> - } else
> + } else if (attr == &dev_attr_touchpad.attr)
> + supported = priv->has_touchpad_switch;
> + else
> supported = true;
>
> return supported ? attr->mode : 0;
> @@ -867,6 +870,9 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv)
> {
> unsigned long value;
>
> + if (!priv->has_touchpad_switch)
> + return;
> +
> /* Without reading from EC touchpad LED doesn't switch state */
> if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) {
> /* Some IdeaPads don't really turn off touchpad - they only
> @@ -989,6 +995,9 @@ static int ideapad_acpi_add(struct platform_device *pdev)
> priv->platform_device = pdev;
> priv->has_hw_rfkill_switch = dmi_check_system(hw_rfkill_list);
>
> + /* Most ideapads with ELAN0634 touchpad don't use EC touchpad switch */
> + priv->has_touchpad_switch = !acpi_dev_present("PNP0C50", "ELAN0634", -1);
> +
That is not how acpi_dev_present works:
/**
* acpi_dev_present - Detect that a given ACPI device is present
* @hid: Hardware ID of the device.
* @uid: Unique ID of the device, pass NULL to not check _UID
* @hrv: Hardware Revision of the device, pass -1 to not check _HRV
*
* Return %true if a matching device was present at the moment of invocation.
...
*/
bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
The second argument tests for the UID, which is typically "1", "2", "3",
etc. and which is used when there are multiple devices with the same HID.
For example the GPIO controllers on many Intel chipsets have so called south
and north islands, which are separate devices with the same HID, but one
has a UID of "1" and the other of "2".
If you want to check for a device with a HID or CID of "ELAN0634" then you
should do:
priv->has_touchpad_switch = !acpi_dev_present("ELAN0634", NULL, -1);
Regards,
Hans
> ret = ideapad_sysfs_init(priv);
> if (ret)
> return ret;
> @@ -1006,6 +1015,10 @@ static int ideapad_acpi_add(struct platform_device *pdev)
> if (!priv->has_hw_rfkill_switch)
> write_ec_cmd(priv->adev->handle, VPCCMD_W_RF, 1);
>
> + /* The same for Touchpad */
> + if (!priv->has_touchpad_switch)
> + write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, 1);
> +
> for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++)
> if (test_bit(ideapad_rfk_data[i].cfgbit, &priv->cfg))
> ideapad_register_rfkill(priv, i);
>
prev parent reply other threads:[~2021-01-04 11:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-03 3:36 Jiaxun Yang
2021-01-04 11:26 ` Hans de Goede [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=60493709-e0f6-2079-7007-67e85445d2dc@redhat.com \
--to=hdegoede@redhat.com \
--cc=ike.pan@canonical.com \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgross@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®