BYD touchpad multi-touch support?

I’m switching from a Mac and I really miss using two fingers to scroll and perform right clicks. Is it possible to hack the functionality into a Librem 13" or is the hardware just not capable of it?

What OS are you using on your Librem? It should have some basic two-finger functionality with PureOS.

For the record I was never able to activate any kind of two-finger scroll with any distribution I tried on my librem13 (the PureOS version which was installed on the laptop, Ubuntu, Debian).

The touchpad is one of the weakness of the librem-13v1.

Things just get worse: since a couple of days my touchpad is not recognized at all on my Debian testing (which use linux kernel 4.9.0-1-amd64) : I need to use an external mouse. I did not had time to investigate any further for now (fed up to have so many trouble with the bad basic linux support of it) nor did had time to contact the support, but I am afraid that this may be an hardware problem (my laptop is only one year old or so).

byd driver is disabled by default in newer kernel versions, enable it by putting

echo -n "byd" > /sys/bus/serio/devices/serio1/protocol

to /etc/rc.local.

cat /etc/rc.local should give you following:

#!/bin/bash
echo -n "byd" > /sys/bus/serio/devices/serio1/protocol

Make sure the script is executable.

2 Likes

This does not change anything for now, which may confirm my first impression of an hardware failure.

I however get the device presence acknowledgement in the log:

[10677.671745] input: BYDPS/2 BYD TouchPad as /devices/platform/i8042/serio1/input/input27

I will try to investigate it more deeply tonight.

I just updated my effectively-debian-stretch (testing) install after a while, and the touchpad also went “useless” after booting debian kernel 4.9.x. I figured out that it’s stuck in the upper-right corner, you can drag it down a bit with multiple fingers and great effort, but it quickly jumps back to that corner. Downgrading to a previous kernel (4.7.x, it’s been a while since I updated) fixed it, so it’s a driver issue.

I haven’t tried the enable-byd-in-sysfs thing yet, will do that now …

(Yes, it’s rather disappointing that this Linux-focused laptop has a bad upstream kernel driver for the touchpad.)

Writing “byd” (and no newline) to /sys/bus/serio/devices/serio1/protocol worked for me, made the touchpad work again (with the familiar lack of multi-touch).

Anyone being able to make the multi-touch work on librem-13v1?

I also came across this issue on upgrade to the latest PureOS (on a Librem 15v2), where the touchpad mouse pointer was stuck in the top-right corner of the screen. Writing “byd” to /sys/bus/serio/devices/serio1/protocol also solved that issue. After that, the https://github.com/jayk/psmouse-bydfull-dkms/ driver enabled two-finger scrolling (although in exchange for tap-to-click)

1 Like

Just tried updating byd_init_param (changing 0x02 to 0x01 beside disable tapping, currently l.55) of psmouse-bydfull/byd.c and recompiling, based on the values here https://github.com/torvalds/linux/blob/master/drivers/input/mouse/byd.c to try tap-to-click with two-finger still working and seems to be successful! Also happy to discover that three-finger scroll right (specifically) triggers Back in FF (i.e. BTN_SIDE).

2 Likes

Phil, thank you, I’ll let our devs know about this, we might include this driver in PureOS.

2 Likes

Great, thanks Mladen! Aside from cutting down on comments and missing recent changes, it looks like it may not be hugely far from the current byd.c in the tree, but with different defaults and a right-click area with a couple of other features added.

I was very disappointed by the poor BYD driver that can be activated as @mladen described. I gave the “DKMS module for BYD multitouch touchpads” on Github a try. I am running Fedora 26 and this How-To might also work for other rpm-based distributions. First of all psmouse is compiled builtin in Fedora. You cannot replace the module without recompiling the kernel with psmouse as a module. Or at least I did not find a way around this. I’ve followed these instructions to recompile the kernel. Make sure you carefully follow the steps 1-4 and 6. 5 is not needed. Here is what I’ve done:

In step 1:
$ su -
# dnf install rpmdevtools numactl-devel pesign
# dnf builddep -y kernel
# exit

In step 2:
$ dnf download --source kernel
$ rpm -i kernel-*.src.rpm
$ cd rpmbuild

In step 3:
Replaced “# define buildid .local” with “% define buildid .local” in SPECS/kernel.spec. Uncommenting this will add “.local.” to the new kernel. Otherwise you’ll overwrite the currently running kernel while installing.

In step 4:
$ rpmbuild -bp SPECS/kernel.spec
$ cd BUILD/kernel-/linux-
$ cp .config{,.org}
$ make menuconfig
In the kernel configuration menu go to “Input device support --> Mice”. There you should have " PS/2 mouse". Select it and type so that that line changes to " PS/2 mouse". After this select “Save” at the bottom, save your change to .config and Exit. Check if “MOUSE_PS2” is set to “m” in ./.config.

This step is important, - otherwise the kernel will not have the psmouse module: The file as in the How-To “config-x86_64-generic” doesn’t exist. You have to set “MOUSE_PS2” to “m” in SOURCES/kernel-x86_64-config. I did this like this:
$ cd …/…/…
$ sed -i ‘s/MOUSE_PS2=y/MOUSE_PS2=m/’ SOURCE/kernel-x86_64-config

It also might be possible to add MOUSE_PS2=m to kernel-local but I did not test this.

In step 6 build and install the custom kernel:
$ rpmbuild -ba --without debug --without doc --without perf
–without tools --without debuginfo --without kdump
–without bootwrapper --without cross_headers SPECS/kernel.spec
$ su -
# dnf install -y RPMS/x86_64/*.rpm
# reboot

After a reboot the psmouse module is available. Make sure the kernel selected in GRUB is the one that contains the string “.local.”. Now follow the instructions for the “DKMS module for BYD multitouch touchpads” on Github to replace the module with the improved one. This works without any modifications. Of course the module could be replaced while rebuilding the custom kernel.

With this module the touchpad works a lot better and with two-finger scroll. And tabbing can be enabled as described by @phil_weir. It also works quite well.

To me, yes, this works but still I would prefer a better touchpad. Now I have to recompile the kernel on every release which is not acceptable.

1 Like

@smirta, it was a lot easier to install it on PureOS. I guess mainlining that driver will be the right path to go. We would need to contact the author of the patch to see if he is interested in this. So far we can offer it to PureOS users via software center (this is currently in discussion with our devs).

1 Like

Having the same issue on qubes after the latest dom0 upgrade. Suddenly the touchpad isn’t working as expected. Using a librem13. The suggested fix of editing /sys/bus/serio/devices/serio1/protocol won’t work because of file perms. I’m getting the error in nano of “error writing invalild argument”. The suggested rc.local fix also won’t run and make this edit for some reason. I was able to add an older kernel to rollback behaviour but this is problematic because it now means I won’t be able to update dom0 without introducing this problem. How can this issue be fixed on Qubes 3.2 systems?

Make sure you’re root when you try to write to /sys/bus/serio/devices/serio1/protocol.

I’m not sure why Qubes doesn’t seem to run /etc/rc.local automatically. Probably it uses a different file name. For now it is enough to make the fix by hand after every reboot.

Is there a psmouse module? Please check with lsmod | grep psmouse

As far as I can see this problem have all distros with a kernel where psmouse is not compiled as module. I’m expecting Debian-based distros will have this compiled builtin in the future. Whom do you mean by “author of the patch”?

Also the newer Fedora releases on QubesOS need a kernel recompiled as in my How-To. I’m sure some Librem owner already ran into that problem.

1 Like

Hey guys, primary reverse-engineerer and author of the BYD touchpad driver found in the psmouse kernel module here.

Just wanted to give y’all some context of the trade-offs between the ‘official’ kernel driver ( ie the one enabeld by writing ‘byd’ to serio1/protocol ) vs this DKMS driver smirta linked to. It’s been awhile since I’ve had my head in this space so some of the following details might be a bit off, but they should be mostly correct.

Custom DKMS

The DKMS driver handles things like scroll events and multi-touch gestures in hardware on the touchpad itself. The gesture recognition is fairly terrible and laggy, especially when compared to other modern multi-touch devices you’re used to (such as a macbook, for instance).

The device also has no (known) way to expose information on individual multi-touch events the modern multi-touch input stacks need to provide good user experience (finger location, pressure, etc). The hardware only exposes single-finger absolute position packets, but with single byte resolution in each dimension, and no pressure information. Modern multi-touch device drivers simply report finger touch location and pressure to the user-space layer (libinput, synaptics) and do all gesture recognition at that level, which theoretically gives users for fine-grained control over sensitivity settings, left/right click locations, gestures, etc.

Built-in PSMOUSE

The BYD driver built into the psmouse kernel module (when enabled) disables all the various hardware-detected gestures and does not support its ‘multi-touch’ modes. It reports the device to the user-space input layer as a single-touch absolute position touchpad and reports single-finger touch location/movement and hardware left/right mouse clicks.

The driver gets around the 1-byte resolution limitation mentioned above by using the absolute position events as a beginning ‘anchor point’ for mouse movements, and then updates the position using relative movement packets. The provided relative movement packets have a much higher resolution, so while the absolute packets resolution is only 255x255 we can effectively provide location data with a ‘virtual’ resolution of 11264x6656.

By providing raw location data, synaptics and libinput integration is pretty good and you can enable various settings from your window-manager’s mouse settings page and associated configuration tools. In modern Gnome3 at least, you can enable tap to click, natural scrolling, and edge scrolling (though annoyingly the dialog assumes that since it’s a touchpad, it offers a two-finger scroll option which does nothing besides dash your hopes).

If you’re using libinput rather than synaptics, you get ‘disable the touchpad when typing’ for free (which in my experience is a must-have with this hardware). Synaptics, if I recall correctly, provides much more fine-grained control for the power-user to tweak.

One downside is that have to manually enable the BYD driver. This is because it cannot be enabled by default in the Linux kernel as the BYD hardware provides no unique ‘handshake’ to identify itself. IE, when this driver is enabled a generic PS/2 mouse will successfully go through the BYD initialization and then promptly not work as the driver expects some other things besides generic PS/2 packets.

TLDR:

Custom DKMS:

+ multi-touch gesture support
- no individual finger reporting
- not configurable through window-manager settings pages
- no tap-to-click (this could be implemented)
- no natural scrolling (this could be implemented)

Built-in PSMOUSE:

- only single-touch support
+ configurable through window-manager settings pages
+ tap-to-click (if you want it)
+ edge scrolling (if you want it)
+ smoother, more fine-grained scroll experience with software edge scrolling compared to hardware two-finger scrolling
- no two-finger scrolling
+ natural scrolling (if you want it)
+ disables mouse events while typing (libinput only)
- have to modify “/sys/bus/serio/devices/serio1/protocol” to enable :frowning:
- cannot play nicely with generic PS/2 mice (though not really an issue with the Librem series)

7 Likes