thoughtexpo

... @leelavg's corner on the internet, night or day, small or big.

Disable Touchscreen in Fedora

2023-Aug-13 • Tags: fedora

I wasn't able to find any option in BIOS to disable the touchscreen in my ThinkPad X1C laptop and even after spending a considerable time in searching for the same I didn't land on any post explaining a straight forward solution.

Here I'm noting down the solution which is working for almost half an year without any changes. I tried a fair share of experimenting with udev rules, however due to how the PCI enumerates devices the results weren't consistent.

Another challenge was multiple devices sharing same driver and when the driver itself is unloaded then all these devices would fail to work, for example, intel-lpss is shared by touchpad and touchscreen.

Find the input device §

It goes without saying that touchscreen is one of the input devices and so we start off finding all the input devices, then isolate the device which responds to touchscreen events.

I found evtest over lshw more helpful at this task. First install the package via sudo dnf install evtest

Below is the output when evtest is run on my laptop:

1-> sudo evtest
2No device specified, trying to scan all of /dev/input/event*
3Available devices:
4/dev/input/event0: Sleep Button
5/dev/input/event1: Lid Switch
6/dev/input/event10: Video Bus
7/dev/input/event11: Intel HID events
8/dev/input/event12: PC Speaker
9/dev/input/event13: ThinkPad Extra Buttons
10/dev/input/event14: sof-hda-dsp Mic
11/dev/input/event15: sof-hda-dsp Headphone
12/dev/input/event16: sof-hda-dsp HDMI/DP,pcm=3
13/dev/input/event17: sof-hda-dsp HDMI/DP,pcm=4
14/dev/input/event18: sof-hda-dsp HDMI/DP,pcm=5
15/dev/input/event2: Power Button
16/dev/input/event3: AT Translated Set 2 keyboard
17/dev/input/event4: TPPS/2 Elan TrackPoint
18/dev/input/event5: ELAN0672:00 04F3:3187 Mouse
19/dev/input/event6: ELAN0672:00 04F3:3187 Touchpad
20/dev/input/event7: ELAN901C:00 04F3:2C29
21/dev/input/event8: ELAN901C:00 04F3:2C29 UNKNOWN
22/dev/input/event9: ELAN901C:00 04F3:2C29 UNKNOWN
23Select the device event number [0-18]: ^C

One of the input devices highlighted above should be responding to touchscreen events. The reason for choosing these are ELAN (touch controller electronics) and Mouse/Tochpad.

In my case I've selected 7, touched the screen and can see the events generated in output of evtest, it can be different in your case.

1[...]
2/dev/input/event9: ELAN901C:00 04F3:2C29 UNKNOWN
3Select the device event number [0-18]: 7
4Input driver version is 1.0.1
5Input device ID: bus 0x18 vendor 0x4f3 product 0x2c29 version 0x100
6Input device name: "ELAN901C:00 04F3:2C29"
7Supported events:
8 Event type 0 (EV_SYN)
9 Event type 1 (EV_KEY)
10 Event code 330 (BTN_TOUCH)
11[...]
12# below are the generated events
13Properties:
14 Property type 1 (INPUT_PROP_DIRECT)
15Testing ... (interrupt to exit)
16Event: time 1691912451.145747, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 28
17Event: time 1691912451.145747, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 2482
18Event: time 1691912451.145747, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1392
19[...]
20Event: time 1691912451.381050, -------------- SYN_REPORT ------------
21Event: time 1691912451.387687, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
22Event: time 1691912451.387687, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
23Event: time 1691912451.387687, type 4 (EV_MSC), code 5 (MSC_TIMESTAMP), value 238800
24Event: time 1691912451.387687, -------------- SYN_REPORT ------------
25^C

Find the Kernel representation of the device §

Find the device under /sys/bus/hid/devices corresponding to the ID highlighted in above listing, i.e, bus 0x18 vendor 0x4f3 product 0x2c29. /sys/bus is the generic path to find the devices & drivers, hid is Human Interface Devices.

-> ls /sys/bus/hid/devices/*2C29* -d
/sys/bus/hid/devices/0018:04F3:2C29.0002

All that's left is to unbind the driver for this device, thereby we don't respond to the events generated by this device.

Unbind the device §

We can simply echo the device ID to /sys/bus/hid/drivers/hid-multitouch/unbind and all the events from touchscreen will be dropped.

-> echo 0018:04F3:2C29.0002 | sudo tee /sys/bus/hid/drivers/hid-multitouch/unbind
0018:04F3:2C29.0002

The ID after the dot (0002) can change after a reboot during PCI device enumeration, as a result we need to grab the device ID from /sys/bus/hid/devices and unbind it.

After performing above, we can confirm that this device doesn't show up in sudo evtest.

Create systemd unit to automate unbind §

Create a systemd unit file, reload the daemon and enable the unit. After reboot, events from touchscreen will be dropped.

# replace the value with your device product id
# note: use capitalized hex values
-> product_id="2C29"
-> sudo tee /etc/systemd/system/disable-touchscreen.service > /dev/null << EOF
[Unit]
Description=Unbind touchscreen device

[Service]
Type=oneshot
ExecStart=/bin/bash -c "basename \$(ls /sys/bus/hid/devices/*$product_id* -d) > /sys/bus/hid/drivers/hid-multitouch/unbind"
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

-> sudo systemctl daemon-reload && sudo systemctl enable disable-touchscreen.service

Please drop a note if you find a way to disable the touchscreen in the BIOS/UEFI, I believe above solution just stops responding to the events generated by this device but not forget this device altogether, so I suspect this still draws battery even though a reduced amount.

Send an email for any comments. Kudos for making it to the end. Thanks!