diff --git a/documentation/TOUCHPAD_TROUBLESHOOTING.md b/documentation/TOUCHPAD_TROUBLESHOOTING.md new file mode 100644 index 0000000..3f24f7a --- /dev/null +++ b/documentation/TOUCHPAD_TROUBLESHOOTING.md @@ -0,0 +1,98 @@ +# Touchpad Troubleshooting - Little Rascal (Lenovo Yoga Slim 7) + +## Problem +The touchpad on little-rascal (Lenovo Yoga Slim 7 14ARE05) is not working. The trackpad is detected as an I2C HID device but is being misidentified as a sensor hub instead of a proper touchpad. + +## Hardware Details +- **Model**: Lenovo Yoga Slim 7 14ARE05 +- **Touchpad Controller**: ITE8353 (I2C HID) +- **Device Path**: `/sys/bus/i2c/devices/i2c-ITE8353:00` +- **HID Device**: `0018:048D:8353.0001` +- **ACPI ID**: `PNP0C50` (HID-over-I2C precision touchpad) + +## Investigation Results + +### Device Detection +The touchpad controller is properly detected by the kernel: +- I2C device exists at `i2c-ITE8353:00` +- Driver binding: `i2c_hid_acpi` +- HID device: `0018:048D:8353.0001` + +### Problem: Misidentified as Sensor Hub +The device is being bound to `hid-sensor-hub` driver instead of a proper touchpad driver like `hid-multitouch`. + +### Attempted Solutions + +1. **Added I2C HID kernel modules**: + - `i2c_hid`, `i2c_hid_acpi`, `hid_multitouch` + - Added to both `boot.kernelModules` and `boot.initrd.availableKernelModules` + +2. **Added kernel parameters**: + - `i2c_hid.debug=1` + - `acpi_enforce_resources=lax` + - `i2c_hid_acpi.probe_defer=1` + +3. **Added udev rules**: + - Attempted to unbind from `hid-sensor-hub` and bind to `hid-multitouch` + - Set proper permissions for the device + +4. **Enabled libinput**: + - Configured touchpad settings in `modules/desktop/input.nix` + - Added input utilities (`evtest`, `xinput`, `libinput-gestures`) + +### Current Status +- ❌ Touchpad still not functional +- ✅ Device is detected by kernel +- ❌ Device is misidentified as sensor hub +- ❌ No input events generated + +## Next Steps to Try + +### Option 1: BIOS Settings +Check BIOS for touchpad mode settings: +- Look for "Touchpad Mode" setting +- Try switching between "Basic" and "Advanced" modes +- Some laptops have I2C/PS2 mode selection + +### Option 2: Kernel Patch +This appears to be a known issue requiring a kernel patch. Research: +- Linux kernel patches for ITE8353 touchpad support +- Check if newer kernels have better support +- Look for device-specific quirks in the kernel + +### Option 3: Force PS/2 Mode +If I2C mode cannot be made to work: +- Try to enable PS/2 emulation mode in BIOS +- Some laptops can fall back to PS/2 touchpad mode + +### Option 4: Custom Driver +- Check if ITE provides Linux drivers +- Look for community-developed drivers for this specific controller + +### Option 5: Firmware Update +- Update laptop firmware/BIOS +- Some touchpad issues are resolved with firmware updates + +## Useful Commands for Further Debugging + +```bash +# Check device binding +ls -la /sys/bus/i2c/devices/i2c-ITE8353:00/driver + +# Check HID devices +cat /sys/bus/i2c/devices/i2c-ITE8353:00/0018:048D:8353.0001/modalias + +# Monitor udev events +udevadm monitor --environment --udev + +# Test input events +evtest + +# Check kernel modules +lsmod | grep -E "(i2c|hid)" +``` + +## References +- [NixOS Hardware Configuration](https://github.com/NixOS/nixos-hardware) +- [Linux I2C HID Documentation](https://www.kernel.org/doc/html/latest/input/devices/i2c-hid.html) +- [Libinput Documentation](https://wayland.freedesktop.org/libinput/doc/latest/) diff --git a/machines/little-rascal/configuration.nix b/machines/little-rascal/configuration.nix index 28de999..0de6aea 100644 --- a/machines/little-rascal/configuration.nix +++ b/machines/little-rascal/configuration.nix @@ -21,6 +21,7 @@ ../../modules/desktop/niri.nix ../../modules/desktop/cosmic.nix ../../modules/desktop/fonts.nix + ../../modules/desktop/input.nix # Development ../../modules/development/tools.nix diff --git a/machines/little-rascal/hardware-configuration.nix b/machines/little-rascal/hardware-configuration.nix index 5345f2d..b057267 100644 --- a/machines/little-rascal/hardware-configuration.nix +++ b/machines/little-rascal/hardware-configuration.nix @@ -20,11 +20,22 @@ "usb_storage" "sd_mod" "sdhci_pci" + # I2C modules for touchpad support + "i2c_hid" + "i2c_hid_acpi" + "i2c_piix4" ]; kernelModules = []; }; - kernelModules = ["kvm-amd"]; # AMD Ryzen system + kernelModules = [ + "kvm-amd" # AMD Ryzen system + # HID and input modules for touchpad + "hid_generic" + "hid_multitouch" + "i2c_hid" + "i2c_hid_acpi" + ]; extraModulePackages = []; }; @@ -58,20 +69,18 @@ enableRedistributableFirmware = true; # Graphics configuration - AMD Radeon Vega (integrated) + # Using open source driver without ROCm and 32-bit support graphics = { enable = true; - enable32Bit = true; + enable32Bit = false; # Disabled 32-bit support - # AMD integrated graphics drivers + # AMD open source graphics drivers only extraPackages = with pkgs; [ amdvlk # AMD Vulkan driver - rocmPackages.clr.icd # OpenCL support + # Removed ROCm packages for simpler configuration ]; - # 32-bit support for compatibility - extraPackages32 = with pkgs.driversi686Linux; [ - amdvlk - ]; + # No 32-bit support packages needed }; # Bluetooth support for Intel AX200 @@ -81,6 +90,17 @@ }; }; + # Additional services for touchpad support + services.udev.extraRules = '' + # ITE8353 touchpad support - try to force proper driver binding + SUBSYSTEM=="i2c", KERNEL=="i2c-ITE8353:00", MODE="0664", GROUP="input" + SUBSYSTEM=="input", ATTRS{name}=="ITE8353:00*", MODE="0664", GROUP="input" + # Additional HID rules for touchpads + KERNEL=="hidraw*", ATTRS{idVendor}=="048d", ATTRS{idProduct}=="8353", MODE="0664", GROUP="input" + # Force unbind from hid_sensor_hub and rebind to hid_multitouch for ITE8353 + ACTION=="add", SUBSYSTEM=="hid", ATTRS{idVendor}=="048d", ATTRS{idProduct}=="8353", ATTR{bInterfaceClass}=="03", ATTR{bInterfaceSubClass}=="01", ATTR{bInterfaceProtocol}=="02", RUN+="/bin/sh -c 'echo $kernel > /sys/bus/hid/drivers/hid-sensor-hub/unbind; echo $kernel > /sys/bus/hid/drivers/hid-multitouch/bind'" + ''; + # Power management for AMD Ryzen 7 4700U powerManagement = { enable = true; @@ -106,6 +126,12 @@ boot.kernelParams = [ # Enable AMD graphics performance "amdgpu.ppfeaturemask=0xffffffff" + # I2C HID touchpad parameters + "i2c_hid.debug=1" + # Ensure ACPI devices are properly detected + "acpi_enforce_resources=lax" + # Force ITE touchpad to be recognized as input device + "i2c_hid_acpi.probe_defer=1" ]; # TLP for better power management (alternative to power-profiles-daemon) diff --git a/modules/desktop/input.nix b/modules/desktop/input.nix new file mode 100644 index 0000000..9d2b0ac --- /dev/null +++ b/modules/desktop/input.nix @@ -0,0 +1,54 @@ +# Input Configuration Module +# Handles touchpad, keyboard, and other input devices +{ + config, + lib, + pkgs, + ... +}: { + # Enable libinput for touchpad support + # This is the recommended touchpad driver for NixOS since 17.09 + services.libinput = { + enable = true; + + # Touchpad-specific settings + touchpad = { + # Enable tap-to-click (can be disabled if unwanted) + tapping = true; + + # Enable two-finger scrolling + scrollMethod = "twofinger"; + + # Enable natural scrolling (macOS-style, disable if you prefer traditional) + naturalScrolling = false; + + # Disable touchpad while typing to prevent accidental input + disableWhileTyping = true; + + # Middle button emulation (three-finger tap) + middleEmulation = true; + }; + + # Mouse settings (for external mice) + mouse = { + # Standard settings for mice + naturalScrolling = false; + accelProfile = "adaptive"; + }; + }; + + # Additional input packages that might be useful + environment.systemPackages = with pkgs; [ + # Input device utilities + libinput-gestures # For custom touchpad gestures + evtest # For testing input devices + xorg.xinput # X11 input device utility (still useful in Wayland) + ]; + + # Enable support for additional input methods if needed + # (This is separate from touchpad functionality) + i18n.inputMethod = { + enable = false; # Set to true if you need input methods for other languages + # type = "ibus"; # Uncomment and configure if needed + }; +} diff --git a/scripts/diagnose-trackpad.sh b/scripts/diagnose-trackpad.sh new file mode 100755 index 0000000..022bac1 --- /dev/null +++ b/scripts/diagnose-trackpad.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +# Trackpad Diagnostic Script for Little-Rascal +# This script helps diagnose trackpad issues on NixOS + +echo "=== Little-Rascal Trackpad Diagnostics ===" +echo "Date: $(date)" +echo + +echo "1. Checking for input devices..." +if command -v libinput >/dev/null 2>&1; then + echo " ✓ libinput is available" + echo " Input devices detected by libinput:" + sudo libinput list-devices | grep -E "(Device:|Capabilities:)" | head -20 +else + echo " ✗ libinput not found - this could be the problem!" +fi +echo + +echo "2. Checking systemd services..." +if systemctl is-active --quiet systemd-logind; then + echo " ✓ systemd-logind is running" +else + echo " ✗ systemd-logind is not running" +fi +echo + +echo "3. Checking for trackpad hardware..." +if ls /dev/input/mouse* >/dev/null 2>&1; then + echo " ✓ Mouse devices found:" + ls -la /dev/input/mouse* +else + echo " ⚠ No mouse devices found in /dev/input/" +fi + +if ls /dev/input/event* >/dev/null 2>&1; then + echo " ✓ Event devices found:" + ls -la /dev/input/event* | wc -l + echo " Total event devices: $(ls /dev/input/event* | wc -l)" +else + echo " ✗ No event devices found" +fi +echo + +echo "4. Checking kernel modules..." +modules=("i2c_hid" "hid_multitouch" "psmouse") +for module in "${modules[@]}"; do + if lsmod | grep -q "$module"; then + echo " ✓ $module module is loaded" + else + echo " ⚠ $module module not loaded (may not be needed)" + fi +done +echo + +echo "5. Checking for specific laptop touchpad info..." +if command -v dmesg >/dev/null 2>&1; then + echo " Recent touchpad-related kernel messages:" + dmesg | grep -i -E "(touchpad|synaptics|elan|input)" | tail -5 +fi +echo + +echo "6. User permissions..." +echo " Current user: $(whoami)" +echo " User groups: $(groups)" +if groups | grep -q input; then + echo " ✓ User is in 'input' group" +else + echo " ⚠ User not in 'input' group (usually not required on NixOS)" +fi +echo + +echo "=== Recommendations ===" +echo "If trackpad still doesn't work after enabling libinput:" +echo "1. Reboot the system to ensure all changes take effect" +echo "2. Try: sudo libinput debug-events (to see if events are being detected)" +echo "3. Check dmesg for hardware detection issues" +echo "4. Consider adding specific kernel modules if hardware isn't detected" +echo + +echo "=== Configuration Status ===" +if grep -q "services.libinput.enable.*true" /etc/nixos/configuration.nix 2>/dev/null; then + echo " ✓ libinput appears to be enabled in configuration" +else + echo " ⚠ libinput may not be enabled - check your NixOS configuration" +fi