quo / ithc-linux

Linux driver for Intel Touch Host Controller
37 stars 7 forks source link

SP8 support #4

Closed j4ckgrey closed 2 years ago

j4ckgrey commented 2 years ago

Hi there, i installed the module on Surface pro 8 on Ubuntu and when checking it with dmesg got this output

jackgrey@jackgrey-Surface-Pro-8:~/ithc-linux$ sudo dmesg | grep ithc [ 1.694464] ithc: loading out-of-tree module taints kernel. [ 1.694484] ithc: module verification failed: signature and/or required key missing - tainting kernel [ 1.696822] ithc 0000:00:10.6: enabling device (0000 -> 0002) [ 1.916007] ithc 0000:00:10.6: config: e0000002 00000000 001fc0ff 00000010 00000014 43495424 08e300e8 0c37045e 00000001 0cbc4bea fb190781 00000000 e8919552 00040302 62f12ab8 628c8830 [ 1.916455] ithc 0000:00:10.6: registered device ithc [ 1734.766353] ithc 0000:00:10.6: config: e0000002 00000000 001fc0ff 00000010 00000014 43495424 08e300e8 0c37045e 00000001 0cb84bea fb190781 00000000 e891175a 00040302 62f12ab8 628c8838 [ 1734.767149] ithc 0000:00:10.6: registered device ithc

any solution?

quo commented 2 years ago

The signature message is just a warning. It should go away if you use the DKMS install procedure. But it looks like the module was initialized correctly, so if touch doesn't work I probably need to make some changes for SP8.

If touch isn't working, can you try the following:

Thanks!

j4ckgrey commented 2 years ago

Hi there, I installed using dkms and tried all those steps, yet not working but now I got even longer output from dmesg (P.S now I got it installed twice, once with sudo make install and second with dkms)

jackgrey@jackgrey-Surface-Pro-8:~/ithc-linux$ sudo dmesg | grep ithc [ 1.757597] ithc: loading out-of-tree module taints kernel. [ 1.757668] ithc: module verification failed: signature and/or required key missing - tainting kernel [ 1.758189] ithc 0000:00:10.6: enabling device (0000 -> 0002) [ 1.977430] ithc 0000:00:10.6: config: e0000002 00000000 001fc0ff 00000010 00000014 43495424 08e300e8 0c37045e 00000001 0c3c4bea fb190781 00000000 e8d1154a 00040302 62f02ab8 628c8830 [ 1.978956] ithc 0000:00:10.6: registered device ithc [ 609.721818] [3307] ithc:ithc_probe:366: ithc 0000:00:10.6: starting [ 609.722493] [3307] ithc:waitl:16: ithc 0000:00:10.6: waiting for reg 0x1008 mask 0x00000004 val 0x00000004 [ 609.722543] [3307] ithc:waitl:22: ithc 0000:00:10.6: done waiting [ 609.722616] [3307] ithc:waitl:16: ithc 0000:00:10.6: waiting for reg 0x1008 mask 0x20000000 val 0x20000000 [ 609.722623] [3307] ithc:waitl:22: ithc 0000:00:10.6: done waiting [ 609.722625] [3307] ithc:ithc_set_spi_config:38: ithc 0000:00:10.6: setting SPI speed to 10, mode 0 [ 609.722676] [3307] ithc:waitl:16: ithc 0000:00:10.6: waiting for reg 0x1008 mask 0x00000004 val 0x00000000 [ 609.722687] [3307] ithc:waitl:22: ithc 0000:00:10.6: done waiting [ 609.722693] [3307] ithc:waitl:16: ithc 0000:00:10.6: waiting for reg 0x10bc mask 0x0000000f val 0x00000002 [ 609.939701] [3307] ithc:waitl:22: ithc 0000:00:10.6: done waiting [ 609.939705] [3307] ithc:waitl:16: ithc 0000:00:10.6: waiting for reg 0x1110 mask 0x00000010 val 0x00000010 [ 609.939747] [3307] ithc:waitl:22: ithc 0000:00:10.6: done waiting [ 609.939749] [3307] ithc:ithc_spi_command:46: ithc 0000:00:10.6: reg command 4, size 64, offset 0 [ 609.939752] [3307] ithc:waitl:16: ithc 0000:00:10.6: waiting for reg 0x1044 mask 0x00000008 val 0x00000000 [ 609.939793] [3307] ithc:waitl:22: ithc 0000:00:10.6: done waiting [ 609.939799] [3307] ithc:waitl:16: ithc 0000:00:10.6: waiting for reg 0x1044 mask 0x00000008 val 0x00000000 [ 609.940045] [3307] ithc:waitl:22: ithc 0000:00:10.6: done waiting [ 609.940109] ithc 0000:00:10.6: config: e0000002 00000000 001fc0ff 00000010 00000014 43495424 08e300e8 0c37045e 00000001 8cbc4bea fb190781 00000000 e891975a 00040302 62f1aab8 628c8830 [ 609.940114] [3307] ithc:ithc_set_spi_config:38: ithc 0000:00:10.6: setting SPI speed to 4, mode 3 [ 609.940157] [3307] ithc:ithc_spi_command:46: ithc 0000:00:10.6: reg command 6, size 4, offset 12 [ 609.940160] [3307] ithc:waitl:16: ithc 0000:00:10.6: waiting for reg 0x1044 mask 0x00000008 val 0x00000000 [ 609.940206] [3307] ithc:waitl:22: ithc 0000:00:10.6: done waiting [ 609.940210] [3307] ithc:waitl:16: ithc 0000:00:10.6: waiting for reg 0x1044 mask 0x00000008 val 0x00000000 [ 609.940456] [3307] ithc:waitl:22: ithc 0000:00:10.6: done waiting [ 609.940505] [3307] ithc:ithc_dma_rx_init:119: ithc 0000:00:10.6: allocating rx buffers: num = 32, size = 16384, pages = 4 [ 609.940848] ithc 0000:00:10.6: registered device ithc [ 609.940851] [3307] ithc:ithc_dma_tx_init:144: ithc 0000:00:10.6: allocating tx buffers: size = 8192, pages = 2 [ 609.941402] [3307] ithc:ithc_probe:426: ithc 0000:00:10.6: started [ 667.593779] ithc 0000:00:10.6: enabling multi-touch mode [ 667.593783] [3317] ithc:ithc_dma_tx_unlocked:231: ithc 0000:00:10.6: dma tx command 3, size 2 [ 667.593839] [3317] ithc:waitb:27: ithc 0000:00:10.6: waiting for reg 0x1098 mask 0x01 val 0x00 [ 667.594131] [3317] ithc:waitb:33: ithc 0000:00:10.6: done waiting [ 680.745959] ithc 0000:00:10.6: disabling multi-touch mode [ 680.745971] [3317] ithc:ithc_dma_tx_unlocked:231: ithc 0000:00:10.6: dma tx command 3, size 2 [ 680.746018] [3317] ithc:waitb:27: ithc 0000:00:10.6: waiting for reg 0x1098 mask 0x01 val 0x00 [ 680.746275] [3317] ithc:waitb:33: ithc 0000:00:10.6: done waiting

quo commented 2 years ago

Looks like initialization is fine, but no data is coming in. :(

Can you try the following:

If nothing shows up, there's probably some initialization step missing that the SP8 touch hardware needs. Unfortunately I don't have an SP8 to experiment with, but I can take a look at the official SP8 drivers to see if I can find anything. Might take a while though...

j4ckgrey commented 2 years ago

unfortunately nothing is showing after running the dmesg. I understand the hustle, your effort is very much appreciated. If you need me testing anything I would more than happy, you just pm me here and I will test it right away .... making this work is something that would make this device alive. You just let me know if there is anything from my side. Thank you very much

quo commented 2 years ago

That's too bad. I'll let you know if I've found anything, but it will probably take a few weeks at least.

If you want to uninstall the driver in the meantime, the following should work:

j4ckgrey commented 2 years ago

As sad as it may be, I will wait though .... You are kinda of my last hope to use a proper tablet mode on this device xD ... Thank you again for the effort, hope to hear any news soon. Cheers

qzed commented 2 years ago

@quo since ithc has two transport channels, is there any chance that the sp8 uses the other one?

quo commented 2 years ago

It's a possibility, that's why I asked to try the rx0 option, but that didn't seem to help.

Actually, there's one line in ithc-main.c that unconditionally sets a bit in dma_rx[0].unknown_init_bits. I guess there's a remote chance that's actually a "disable" bit, so maybe commenting that line out could help. But I really doubt it. (EDIT: Setting the same bit in dma_rx[1] doesn't seem to disable rx1.)

I'm a little worried by the weird firmware version number 0x8cbc4bea = 140.188.75.234. My SP7+ has 5.0.138.139. If the SP8 uses completely different firmware, there could be a lot of changes in the interface.

quo commented 2 years ago

@j4ckgrey Could you try the following change? So basically changing DEVCFG_SPI_MODE(...) to 2. You can use make run to rebuild, reinstall, and reload the driver. And could you also try with 0 and 1? (Even if 2 works, I'd like to see if any other values work.)

diff --git a/src/ithc-main.c b/src/ithc-main.c
index b0479ca..22551ed 100644
--- a/src/ithc-main.c
+++ b/src/ithc-main.c
@@ -320,7 +320,7 @@ static int ithc_init_device(struct ithc *ithc) {
        }
        ithc_log_regs(ithc);

-       CHECK_RET(ithc_set_spi_config, ithc, DEVCFG_SPI_MAX_FREQ(ithc->config.spi_config), DEVCFG_SPI_MODE(ithc->config.spi_config));
+       CHECK_RET(ithc_set_spi_config, ithc, DEVCFG_SPI_MAX_FREQ(ithc->config.spi_config), 2);
        CHECK_RET(ithc_set_device_enabled, ithc, true);
        ithc_log_regs(ithc);
        return 0;
gurrgur commented 2 years ago

Just tested this and it now touch works in single touch mode on my SP8! Give me a moment and I'll test whether multitouch works using the modified version of iptsd..

j4ckgrey commented 2 years ago

That's good news, i will test tomorrow after work, hope we can get this to work. Thanks for keeping up

gurrgur commented 2 years ago

Okay, so I had to build from commit https://github.com/quo/iptsd/commit/e5bd62c10b8398921cc2f6dc7787a48d8e76a41d since otherwise the build would fail. However the good news is that multitoch works, too. Both axes are flipped, so touches on the bottom left are registered on the top right. But other than that I'm having no issues and multitouch gestures like zooming work fine.

Since iptsd with the sp7+ pen support commit won't build for me I cannot test it unfortunately.

quo commented 2 years ago

Great, thanks! Could you also try the 0 and 1 mode values? (Just out of interest.)

What build error are you getting?

Since the log from j4ckgrey indicates that the device id changed, I'm guessing you had to add a config file for iptsd? You can flip the coordinates by setting InvertX/InvertY in the config file.

gurrgur commented 2 years ago

Aaand I found the reason for flipped axes. I had prevously added a surface-pro8.conf file to iptsd/etc/config which contained

InvertX = true
InvertY = true

Setting these to false "unflips" both axes. Here is the surface-pro8.conf I'm using: surface-pro8.zip

gurrgur commented 2 years ago

Great, thanks! Could you also try the 0 and 1 mode values? (Just out of interest.)

0 and 1 work both in interrupt and poll mode with both single and multitouch. There does not seem to be any functional difference to mode 2. In each case I rebuild and installed ithc using make clean && make && sudo make install, then stopped iptsd using systemctl stop iptsd.service and finally reloaded the kernel module with modprobe -r ithc; modprobe ithc (in a root shell). The changes should have applied right?

What build error are you getting?

Here is the build log:

iptsd-build-log.zip

quo commented 2 years ago

Yeah, the changes should have applied. For SP7+, only mode 0 works, so that's interesting. I figured mode 0 would probably also work for SP8, since that's what's used for reading config. But the Windows driver maps mode 3 to 2, so I've fixed it by doing that as well.

I've added your config file, but I changed the width/height, because according to Google the SP8 display is 2880x1920. (The values don't actually seem to affect anything though, as far as I can tell.)

Build errors should also be fixed now.

quo commented 2 years ago

Whoops, looks like the width/height are supposed to be mm*10(?), not px. I've changed it (calculated based on published ppi, might not be completely accurate).