@wangjun

Thank you for sharing the results and investigating this touchpad issue!

One thing confuses me is for the ELAN touchpad, no single interrupt
fires when you put finger on the touchpad while for the Synaptics
touchpad, you still see interrupts firing but with a very rate of ~7Hz.
Judging from the ACPI DSDT tables, different variants of this laptop
model share the same GPIO chip. So this difference is unexpected.
Understanding the difference may help us why the GPIO interrupt
controller is malfunctioning.

Based on your results, I guess the ELAN touchpad somehow de-asserts its
interrupt line connected to the GPIO pin. Could you further do the
following experiment?

The following C program is to let GPIO controller quickly generate some
interrupts then disable the firing of interrupts by toggling pin#130's
direction with an time interval (ms). For the Synaptics touchpad, There
is no interrupt firing unless internal > 120ms. So somehow the GPIO
controller can only generate interrupt when its pin holding the signal
for enough time. My hypothesis is the GPIO is not setup properly so it
stays in a idle state or it's clock frequency is too small (so I don't
think the touchpad issue is caused by mis-configuration of the direction
of the pin). I want to see if the result from the ELAN touchpad would
also support this hypothesis.


1. Find out the reliable way to trigger an interrupt which is crucial for this 
experiment.

   You told me there will be interrupt firing by simply setting the
pin's direction to "out". You can check it's reliable by following the
steps

    a. Don't put your finger on the touchpad
    b. Open a terminal window and run `sudo dmesg -W`
    c. In another terminal, "cd /sys/class/gpio/gpio386"
    e. "echo out > direction" and see if the following dmesg output will 
keeping popping out in the previous terminal window

        ```
        [ 138.233653] i2c_hid i2c-MSFT0001:00: i2c_hid_get_input: IRQ triggered 
but there's no data
        ```
    d. Then "echo in > direction", now the dmesg output in step 3 should stop 
popping out.
    f. Repeat step e-d for around 5 times

If you are certain now, use the following C Program,
```c
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <fcntl.h>

#include <errno.h>
void write_to_pin130(char *d, size_t size)
{
        int fd;
        fd = open("/sys/class/gpio/gpio386/direction", O_WRONLY);
        write(fd, d, size);
        perror("Status:");
        close(fd);
}
void toggle_pin130(int interval_ms)
{
        struct timespec ts, ts1;

        write_to_pin130("out", 3);

        clock_gettime(CLOCK_MONOTONIC, &ts);

        usleep(interval_ms*1000);

        write_to_pin130("in", 2);
        clock_gettime(CLOCK_MONOTONIC, &ts1);
        printf("Interval: %.1f (real), %d (set)\n", 
(ts1.tv_sec-ts.tv_sec)*1000.0+(ts1.tv_nsec-ts.tv_nsec)/1000.0, interval_ms);

}
int main(int argc, char **argv)
{
        struct timespec ts;
        int interval_ms = atoi(argv[1]);
        toggle_pin130(interval_ms);

}
```


For me, it seems it's reliable to toggle the value to trigger a interrupt. You 
can follow similar steps to test it,

    a. Don't put your finger on the touchpad
    b. Open a terminal window and run `sudo dmesg -W`
    c. In another terminal, "cd /sys/class/gpio/gpio386"
    e. "echo 1 > value" and see if the following dmesg output will keeping 
popping up in the previous terminal window

        ```
        [ 138.233653] i2c_hid i2c-MSFT0001:00: i2c_hid_get_input: IRQ triggered 
but there's no data
        ```
    d. Then "echo 0 > value", now the dmesg output in step 3 should stop 
popping up
    f. Repeat step e-d for around 5 times

If the results are positive, use the following C program,
```
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <fcntl.h>

#include <errno.h>
void write_to_pin130(char *d)
{
        int fd;
        fd = open("/sys/class/gpio/gpio386/value", O_WRONLY);
        write(fd, d, 1);
        perror("Status:");
        close(fd);
}
void toggle_pin130(int interval_ms)
{
        struct timespec ts, ts1;
        char d = '0';
        write_to_pin130(&d);

        clock_gettime(CLOCK_MONOTONIC, &ts);

        usleep(interval_ms*1000);

        d = '1';
        write_to_pin130(&d);
        clock_gettime(CLOCK_MONOTONIC, &ts1);
        printf("Interval: %.1f (real), %d (set)\n", 
(ts1.tv_sec-ts.tv_sec)*1000.0+(ts1.tv_nsec-ts.tv_nsec)/1000.0, interval_ms);

}
int main(int argc, char **argv)
{
        struct timespec ts;
        int interval_ms = atoi(argv[1]);
        toggle_pin130(interval_ms);

}
```

2. Build (you can simply run `make fire_touchpad_pin_irq.c`) and run it as a 
root user
    $ sudo ./fire_touchpad_pin_irq N

   N is the time interval in ms. You may start with 100 and keep
increasing N it until you see a couple of messages like follows pop up,

        [ 138.233653] i2c_hid i2c-MSFT0001:00: i2c_hid_get_input: IRQ
triggered but there's no data

    With larger N, you will see more messages popping up one time.

-- 
You received this bug notification because you are a member of Desktop
Packages, which is subscribed to xserver-xorg-input-libinput in Ubuntu.
https://bugs.launchpad.net/bugs/1887190

Title:
  MSFT Touchpad not working on Lenovo Legion-5 15ARH05

Status in Pop!_OS:
  New
Status in linux package in Ubuntu:
  Confirmed
Status in xserver-xorg-input-libinput package in Ubuntu:
  Confirmed
Status in linux package in Arch Linux:
  Fix Committed
Status in linux package in Fedora:
  Confirmed
Status in linux package in openSUSE:
  New

Bug description:
  Hello

  The MSFT touchpad of this Lenovo Legion-5 15ARH05 laptop is not reacting at 
all (pointer and click never move when touchpad is touched). This has been 
reported by other users in various websites, with various linux systems 
including other Ubuntu systems, but I saw no launchpad bug so I post one. 
Example of websites covering the issue :
  - https://askubuntu.com/questions/1253830/lenovo-legion-5-touchpad (exactly 
the same laptop)
  - https://www.linux.org/threads/lenovo-legion-5-touchpad.29536/ (similar 
laptop)

  xinput indentifies it as MSFT0001:00 04F3:3140

  Virtual core pointer                          id=2    [master pointer  (3)]
  ⎜   ↳ Virtual core XTEST pointer                      id=4    [slave  pointer 
 (2)]
  ⎜   ↳ MSFT0001:00 04F3:3140 Touchpad                  id=17   [slave  pointer 
 (2)]
  ⎜   ↳ MSFT0001:00 04F3:3140 Mouse                     id=16   [slave  pointer 
 (2)]
  ⎜   ↳ ITE Tech. Inc. ITE Device(8910) Consumer Control        id=12   [slave  
pointer  (2)]
  ⎜   ↳ Logitech USB Optical Mouse                      id=11   [slave  pointer 
 (2)]
  ⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
      ↳ Virtual core XTEST keyboard                     id=5    [slave  
keyboard (3)]
      ↳ Ideapad extra buttons                           id=15   [slave  
keyboard (3)]
      ↳ Power Button                                    id=6    [slave  
keyboard (3)]
      ↳ Integrated Camera: Integrated C                 id=10   [slave  
keyboard (3)]
      ↳ Video Bus                                       id=7    [slave  
keyboard (3)]
      ↳ ITE Tech. Inc. ITE Device(8910) Consumer Control        id=19   [slave  
keyboard (3)]
      ↳ Power Button                                    id=9    [slave  
keyboard (3)]
      ↳ ITE Tech. Inc. ITE Device(8910) Wireless Radio Control  id=13   [slave  
keyboard (3)]
      ↳ ITE Tech. Inc. ITE Device(8910) Keyboard        id=14   [slave  
keyboard (3)]
      ↳ AT Translated Set 2 keyboard                    id=18   [slave  
keyboard (3)]
      ↳ Video Bus                                       id=8    [slave  
keyboard (3)]

  Thanks a lot for your time. It does not help, but I can confirm what
  was reported on askubuntu by another user : the touchpad does work on
  Windows.

  ProblemType: Bug
  DistroRelease: Ubuntu 20.04
  Package: linux-image-5.4.0-40-generic 5.4.0-40.44
  ProcVersionSignature: Ubuntu 5.4.0-40.44-generic 5.4.44
  Uname: Linux 5.4.0-40-generic x86_64
  NonfreeKernelModules: nvidia_modeset nvidia
  ApportVersion: 2.20.11-0ubuntu27.3
  Architecture: amd64
  AudioDevicesInUse:
   USER        PID ACCESS COMMAND
   /dev/snd/controlC0:  nicolas    1567 F.... pulseaudio
   /dev/snd/controlC1:  nicolas    1567 F.... pulseaudio
   /dev/snd/controlC2:  nicolas    1567 F.... pulseaudio
  CasperMD5CheckResult: skip
  CurrentDesktop: ubuntu:GNOME
  Date: Fri Jul 10 20:14:25 2020
  InstallationDate: Installed on 2020-07-02 (8 days ago)
  InstallationMedia: Ubuntu 20.04 LTS "Focal Fossa" - Release amd64 (20200423)
  MachineType: LENOVO 82B5
  ProcEnviron:
   TERM=xterm-256color
   PATH=(custom, no user)
   XDG_RUNTIME_DIR=<set>
   LANG=fr_FR.UTF-8
   SHELL=/bin/bash
  ProcFB: 0 EFI VGA
  ProcKernelCmdLine: BOOT_IMAGE=/vmlinuz-5.4.0-40-generic 
root=UUID=d8898017-2821-434e-ab52-fec76ac93106 ro quiet splash vt.handoff=7
  RelatedPackageVersions:
   linux-restricted-modules-5.4.0-40-generic N/A
   linux-backports-modules-5.4.0-40-generic  N/A
   linux-firmware                            1.187.1
  SourcePackage: linux
  UpgradeStatus: No upgrade log present (probably fresh install)
  dmi.bios.date: 05/12/2020
  dmi.bios.vendor: LENOVO
  dmi.bios.version: EUCN19WW
  dmi.board.asset.tag: NO Asset Tag
  dmi.board.name: LNVNB161216
  dmi.board.vendor: LENOVO
  dmi.board.version: SDK0J40709 WIN
  dmi.chassis.asset.tag: NO Asset Tag
  dmi.chassis.type: 10
  dmi.chassis.vendor: LENOVO
  dmi.chassis.version: Lenovo Legion 5 15ARH05
  dmi.modalias: 
dmi:bvnLENOVO:bvrEUCN19WW:bd05/12/2020:svnLENOVO:pn82B5:pvrLenovoLegion515ARH05:rvnLENOVO:rnLNVNB161216:rvrSDK0J40709WIN:cvnLENOVO:ct10:cvrLenovoLegion515ARH05:
  dmi.product.family: Legion 5 15ARH05
  dmi.product.name: 82B5
  dmi.product.sku: LENOVO_MT_82B5_BU_idea_FM_Legion 5 15ARH05
  dmi.product.version: Lenovo Legion 5 15ARH05
  dmi.sys.vendor: LENOVO
  --- 
  ProblemType: Bug
  ApportVersion: 2.20.11-0ubuntu27.3
  Architecture: amd64
  CasperMD5CheckResult: skip
  CurrentDesktop: ubuntu:GNOME
  DistroRelease: Ubuntu 20.04
  InstallationDate: Installed on 2020-07-02 (12 days ago)
  InstallationMedia: Ubuntu 20.04 LTS "Focal Fossa" - Release amd64 (20200423)
  Package: linux (not installed)
  ProcEnviron:
   TERM=xterm-256color
   PATH=(custom, no user)
   XDG_RUNTIME_DIR=<set>
   LANG=fr_FR.UTF-8
   SHELL=/bin/bash
  Tags:  focal
  Uname: Linux 5.8.0-050800rc5-generic x86_64
  UnreportableReason: The running kernel is not an Ubuntu kernel
  UpgradeStatus: No upgrade log present (probably fresh install)
  UserGroups: adm cdrom dip lpadmin lxd plugdev sambashare sudo
  _MarkForUpload: True

To manage notifications about this bug go to:
https://bugs.launchpad.net/pop-os/+bug/1887190/+subscriptions

-- 
Mailing list: https://launchpad.net/~desktop-packages
Post to     : desktop-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~desktop-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to