linux-surface / linux-surface

Linux Kernel for Surface Devices
4.68k stars 205 forks source link

SP8 touchscreen and pen support #818

Open luca-viggiani opened 2 years ago

luca-viggiani commented 2 years ago

Hi I'm sure that this has already been asked before (maybe several times), but I can't find where. And I know there's some work ongoing about getting touchscreen and pen work on SP8. So what's the status and where can I track it? Thanks!

qzed commented 2 years ago

Main discussion for the touch host controller is going on here: https://github.com/linux-surface/intel-precise-touch/issues/8. That will provide single- and (via IPTSd) multi-touch support. Pen support still requires reverse-engineering the new data format: https://github.com/linux-surface/intel-precise-touch/issues/14.

luca-viggiani commented 2 years ago

Thank'you very much! So at the moment touchscreen is still unsupported as stated in the feature matrix, right?

qzed commented 2 years ago

Yes, but @quo already has a preliminary driver that we can hopefully integrated soon.

BeatVids commented 2 years ago

Great news, I noticed that SP7+ is now supported in the feature matrix. The only unsupported one is now just the SP8. I've tried setting up ITHC, but no luck. Anything we can do now to get it to work for SP8? Please let me know if there's anything I can do to contribute.

j4ckgrey commented 2 years ago

Hi there, I also own SP8, if there is anything I can do to contribute, or testing, please just ask.

quo commented 2 years ago

The ithc driver should work now for SP8. Pen may also work with the experimental iptsd.

j4ckgrey commented 2 years ago

@quo mate, you are a hero. Thanks a lot

luca-viggiani commented 2 years ago

@quo mate, you are a hero. Thanks a lot

@j4ckgrey Hi, have you tested it on SP8?

j4ckgrey commented 2 years ago

@luca-viggiani last night it was tested by another user, and confirmed it in an issue i created in the original driver's post, he confirmed it to be working, multi-touch as well using the IPTSD experimental after some edit was done by quo .... so yeah, I would go ahead and install it then start searching for 120Hz support xD

luca-viggiani commented 2 years ago

@luca-viggiani last night it was tested by another user, and confirmed in an issue i created in the original driver's post, was confirmed to work, multi touch as well using the IPTSD experimental after some edit was done by quo .... so yeah, I would I would go ahead and install it then start searching for 120Hz support xD

That's great thanks!

gurrgur commented 2 years ago

The discussion can be found here: https://github.com/quo/ithc-linux/issues/4

Also I'd like to add that using https://github.com/quo/iptsd pen input works as well on my SP8 with a Slim Pen 2 but there are still some issues with tilt and the eraser not yet being recognized as an eraser (it works just like a regular pen).

j4ckgrey commented 2 years ago

The discussion can be found here: quo/ithc-linux#4

Also I'd like to add that using https://github.com/quo/iptsd pen input works as well on my SP8 with a Slim Pen 2 but there are still some issues with tilt and the eraser not yet being recognized as an eraser (it works just like a regular pen).

did you have any luck bringing 120hz to the screen?

gurrgur commented 2 years ago

Running it at 120Hz with variable refresh rate enabled right now :) I got it working by manually purging all 60Hz modes from the edid in a hex editor. In #825 I describe a slightly different method which enables 120Hz but loses VRR in the process.

This is the edid which has the manual edits: edid-sp8-120hz-vrr-mod.zip

The method for setting up an edid override is still the same as shown in #825.

AFAIK VRR in combination with an Intel iGPU is currently only supported by Plasma Wayland and Sway. Unlike with amdgpu I believe there is no xorg config option which would enable it in an X11 session...

BeatVids commented 2 years ago

I appreciate all you gentlemen for making this easy for everyone to follow. I'm super happy to say I got touch to work on my SP8 as well. Thank you loads @quo

j4ckgrey commented 2 years ago

@quo i didnt get touch working at first so I did enter poll mode (this command: sudo modprobe -r ithc; sudo modprobe ithc poll rx0 logregs dyndbg=+pflmt), and it worked only then in one a single touch mode (I already have Linux-Surface kernel installed), but I tried to install iptsd and I keep getting ERROR: Pkg-config binary for machine 1 not found. Giving up.

Is there something im doing wrong?

quo commented 2 years ago

@j4ckgrey I think you just have to install pkg-config. On Ubuntu you should be able to install it with sudo apt install pkg-config.

As for poll mode, did you get the "Blocked an interrupt request" error in dmesg? If so, it's best to use the intremap=nosid workaround from the readme (sudo make set-nosid should work on Ubuntu).

j4ckgrey commented 2 years ago

@j4ckgrey I think you just have to install pkg-config. On Ubuntu you should be able to install it with sudo apt install pkg-config.

As for poll mode, did you get the "Blocked an interrupt request" error in dmesg? If so, it's best to use the intremap=nosid workaround from the readme (sudo make set-nosid should work on Ubuntu).

Not really, i got no error in dmesg, everything was just running smooth.

Output was : [ 1.751230] ithc: loading out-of-tree module taints kernel. [ 1.751253] ithc: module verification failed: signature and/or required key missing - tainting kernel [ 1.752340] ithc 0000:00:10.6: enabling device (0000 -> 0002) [ 1.974305] ithc 0000:00:10.6: config: e0000002 00000000 001fc0ff 00000010 00000014 43495424 08e300e8 0c37045e 00000001 0ebc4bea fb190781 00000000 e891954a 00040302 22f02ab8 628c8830 [ 1.974730] ithc 0000:00:10.6: registered device ithc

And yet touch wont work. Also I still get an error while installing the iptsd. In the step sudo ./build/iptsd

ERROR: ../src/control.c:139: Failed to open /dev/ipts/0: No such file or directory ERROR: ../src/main.c:106: Failed to start IPTS: No such file or directory

quo commented 2 years ago

Not sure why it wouldn't work without poll in that case... @BeatVids @gurrgur Did you need the nosid or poll workarounds?

I think you may have the wrong iptsd version, you need this one: https://github.com/quo/iptsd

j4ckgrey commented 2 years ago

Not sure why it wouldn't work without poll in that case... @BeatVids @gurrgur Did you need the nosid or poll workarounds?

I think you may have the wrong iptsd version, you need this one: https://github.com/quo/iptsd

This is the iptsd I'm installing .... Im also confused cause it worked with others.

If @BeatVids @gurrgur you guys got any insight please tell, what distro are you using?

gurrgur commented 2 years ago

ERROR: ../src/control.c:139: Failed to open /dev/ipts/0: No such file or directory ERROR: ../src/main.c:106: Failed to start IPTS: No such file or directory

It seems like the ipts kernel module is not loaded? Also the ipts kernel module needs to be loaded with some parameter set otherwise it won't work with gen 7+ devices. Can't remember what it is called (gen7mt or something similar). Running modinfo ipts should get you the name.

So first load the module sudo modprobe ipts gen7mt=1 and then start iptsd.

gurrgur commented 2 years ago

Not sure why it wouldn't work without poll in that case... @BeatVids @gurrgur Did you need the nosid or poll workarounds?

Yes, I needed the nosid workaround but it worked with both poll and interrupts.

quo commented 2 years ago

I see what happened with iptsd; you used the installation instructions in the readme, which are for the old version.

You can remove the iptsd directory you have now, then run the following commands to build and run iptsd:

git clone https://github.com/quo/iptsd
cd iptsd
meson build
ninja -C build
sudo ./build/src/daemon/iptsd

Also the ipts kernel module needs to be loaded

No, you should not need the ipts module for SP8. Only ithc + iptsd.

Yes, I needed the nosid workaround but it worked with both poll and interrupts.

Alright, yeah, then sudo make set-nosid is required on SP8 as well.

luca-viggiani commented 2 years ago

I see what happened with iptsd; you used the installation instructions in the readme, which are for the old version.

You can remove the iptsd directory you have now, then run the following commands to build and run iptsd:

git clone https://github.com/quo/iptsd
cd iptsd
meson build
ninja -C build
sudo ./build/src/daemon/iptsd

Also the ipts kernel module needs to be loaded

No, you should not need the ipts module for SP8. Only ithc + iptsd.

Yes, I needed the nosid workaround but it worked with both poll and interrupts.

Alright, yeah, then sudo make set-nosid is required on SP8 as well.

Hi just a questiona about sudo make set-nosid. I see from the README that this is if you're using GRUB. In my case, as I'm using systemd boot, do I build it normally and then manually add the kernel param intremap=nosid and reboot, right?

j4ckgrey commented 2 years ago

I am going to clean install today again, and hope it works properly this time ... thanks for the follow up, much appreciated.

j4ckgrey commented 2 years ago

PXL_20220601_192850814 @quo I ran all these commands and i get this output .... What am I doing wrong?

git clone https://github.com/quo/iptsd cd iptsd meson build ninja -C build sudo ./build/src/daemon/iptsd

quo commented 2 years ago

Well, it looks like it worked? If touch doesn't work, can you post sudo dmesg output?

j4ckgrey commented 2 years ago

Well, it looks like it worked? If touch doesn't work, can you post sudo dmesg output?

I got touch to work withset-nosid, but iptsd for multi touch is not working ... I ran the commands you sent me, and it stops there

quo commented 2 years ago

It stops there because it's running. :) Multitouch should work while its running like that. If it doesn't, you can try stopping iptsd with Ctrl+C, then reloading the driver with sudo modprobe -r ithc; sudo modprobe ithc, then starting iptsd again.

If multitouch still doesn't work, can you do the following:

quo commented 2 years ago

@luca-viggiani

In my case, as I'm using systemd boot, do I build it normally and then manually add the kernel param intremap=nosid and reboot, right?

Yeah, that should work.

j4ckgrey commented 2 years ago

It stops there because it's running. :) Multitouch should work while its running like that. If it doesn't, you can try stopping iptsd with Ctrl+C, then reloading the driver with sudo modprobe -r ithc; sudo modprobe ithc, then starting iptsd again.

If multitouch still doesn't work, can you do the following:

* stop iptsd again

* `sudo modprobe -r ithc; sudo modprobe ithc`

* `sudo cat /dev/ithc > ithc.dat` (leave this running)

* touch the screen a couple times

* stop the above `cat` command with Ctrl+C

* attach the ithc.dat file that was created (the file contains the raw touch data)

everything is working now, forgive my ignorance im no wizard, just a muggle here. One question though, do I have to run iptsd everytime to have multi touch? cause once i stop it no multi touch

qzed commented 2 years ago

@j4ckgrey Yes, you'll need IPTSd for multi-touch. We're essentially getting raw data that needs to be processed to be usable for the kernel. IPTSd does that and without it you'd have to rely on the built-in fallback mode, which requires no processing but is single-touch only.

j4ckgrey commented 2 years ago

@j4ckgrey Yes, you'll need IPTSd for multi-touch. We're essentially getting raw data that needs to be processed to be usable for the kernel. IPTSd does that and without it you'd have to rely on the built-in fallback mode, which requires no processing but is single-touch only.

Thanks, mate. Thanks to all of you, it's a bless to have such community.

j4ckgrey commented 2 years ago

1 last thing though, I installed Kubuntu and once installed i checked the display settings and it had 120hz display available. Not sure if this can help but maybe we can get this to work on the kernel?

qzed commented 2 years ago

I'm honestly not sure what's preventing this from working or how that could be debugged...

k4ever commented 2 years ago

When will the main installation instructions page be updated to include single touch, multi-touch, and pen support instructions for the Surface Pro 7+ and 8?

qzed commented 2 years ago

@k4ever Well, the plan is to include support in the kernel and IPTSd once it's matured a bit. So instructions don't have to be updated once we "officially" support it. At the moment it's all still work in progress.

j4ckgrey commented 2 years ago

I'm honestly not sure what's preventing this from working or how that could be debugged...

https://github.com/linux-surface/linux-surface/issues/825 this link here gives a solution but its for archlinux, i have ubuntu so i dont really know how to do in ubu tu, maybe we can begin from there?

gurrgur commented 2 years ago

I have done some research on this and for debugging it is very useful to enable dynamic debug messages for kms and the i915 driver. Apparently the 120Hz mode gets pruned because the driver believes that the panel can only operate in "fixed mode" so it takes the preferred mode (which is the 60Hz one) and prunes all other modes with differing refresh rate or resolution.

I actually patched the i915 driver to circumvent the mode pruning which makes both 120 and 60Hz mode available. However even then modesetting just fails and nothing happens after choosing the 120Hz mode.

j4ckgrey commented 2 years ago

@j4ckgrey I think you just have to install pkg-config. On Ubuntu you should be able to install it with sudo apt install pkg-config.

As for poll mode, did you get the "Blocked an interrupt request" error in dmesg? If so, it's best to use the intremap=nosid workaround from the readme (sudo make set-nosid should work on Ubuntu).

hi there, i tried to search the answer before asking you but i failed. How to make set-nosid in archlinux?

quo commented 2 years ago

Depends on the bootloader you're using, see: https://wiki.archlinux.org/title/kernel_parameters

j4ckgrey commented 2 years ago

Depends on the bootloader you're using, see: https://wiki.archlinux.org/title/kernel_parameters

I simply installed manjaro with efi partition

quo commented 2 years ago

From what I can tell sudo make set-nosid should work on Manjaro if using GRUB. Otherwise you'll probably have better luck asking on the Manjaro forums.

If you do get it working, feel free to post the solution here, I might be able to incorporate it into the Makefile.

j4ckgrey commented 2 years ago

From what I can tell sudo make set-nosid should work on Manjaro if using GRUB. Otherwise you'll probably have better luck asking on the Manjaro forums.

If you do get it working, feel free to post the solution here, I might be able to incorporate it into the Makefile.

So I ran the command and I keep getting this error. Do you think Im missing something to install before running the command?

I only wanna make sure Im not missing anything before asking in their forums. Thanks in advance, mate. 1 (2)

NP-chaonay commented 2 years ago

Thanks, mate.

that sh shell doesnt allow stdout pipe output to the path that the subdirectory doesnt existed, you have to do mkdir -p follow with that path (exclude file just dir)

and then re run command,

pls make sure that your installed grub config to read config on that directory (generally should be)

@j4ckgrey

PS1: TBH is it not generally called pipe but stdout redirect, in case of someone confused

j4ckgrey commented 2 years ago

Thanks, mate.

that sh shell doesnt allow stdout pipe output to the path that the subdirectory doesnt existed, you have to do mkdir -p follow with that path (exclude file just dir)

and then re run command,

pls make sure that your installed grub config to read config on that directory (generally should be)

@j4ckgrey

Thanks mate, I will try it right after work .... I wanted to do the same last night but as I do not have enoug knowledge i wanted to avoid fucking up.

j4ckgrey commented 2 years ago

I created the mkdir and the command went through but touch didnt work, here is the output PXL_20220610_193140468

j4ckgrey commented 2 years ago

It only worked when i ran the command sudo modprobe -r ithc; sudo modprobe ithc poll rx0 logregs dynbg=+pflmt

NP-chaonay commented 2 years ago

It only worked when i ran the command sudo modprobe -r ithc; sudo modprobe ithc poll rx0 logregs dynbg=+pflmt

could you try to reboot to grub and see if kernel cmdline is updated, if not then your grub pkg of your distro is not config to read grub config from /etc/default/grub.d. if this happens then it up to implementation of your distro's grub, you have to figure where to set default kernel cmdline and save there

the another easy way is to put intremap=nosid in grub every boot manually

j4ckgrey commented 2 years ago

It only worked when i ran the command sudo modprobe -r ithc; sudo modprobe ithc poll rx0 logregs dynbg=+pflmt

could you try to reboot to grub and see if kernel cmdline is updated, if not then your grub pkg of your distro is not config to read grub config from /etc/default/grub.d. if this happens then it up to implementation of your distro's grub, you have to figure where to set default kernel cmdline and save there

the another easy way is to put intremap=nosid in grub every boot manually

Thanks, I think I will go for Ubuntu again .... Sad part is 120hz did not work there

aleksfadini commented 2 years ago

@quo i didnt get touch working at first so I did enter poll mode (this command: sudo modprobe -r ithc; sudo modprobe ithc poll rx0 logregs dyndbg=+pflmt),

Thank you for this. Just got a SP8, and sudo modprobe -r ithc; sudo modprobe ithc poll rx0 logregs dyndbg=+pflmt worked to get my touchscreen working too (single touch)!! That's amazing!! Infinite thanks you guys are awesome.

On arch, it's just a matter of following the installation guide, then installing ithc after installing the dependencies with pacman, which on arch obviously are: sudo pacman -S dkms linux-surface-headers then install ithc as explained here https://github.com/quo/ithc-linux then reboot, then run sudo modprobe -r ithc; sudo modprobe ithc poll rx0 logregs dyndbg=+pflmt

Having single touch makes it quite tabletable for me!!