Bug#1056904: linux-image-amd64: Module hp_wmi is missing from the configuration. Required for 2 in 1 laptops.
Package: linux-image-amd64
Severity: normal
X-Debbugs-Cc: hagar@aussiebroadband.com.au
Dear Maintainer,
I have been trying to get Tablet/Laptop switching working, along with
touchscreen, rotation and stylus.
The Laptop mode module was missing for the HP x360 2 in 1 laptop.
I recompiled the 6.5.3 kernel with hp_wmi module enabled.
Now the system can tell the difference between Laptop and Tablet modes.
(Script included at end)
The module should have already been enabled allowing easier debugging.
-- System Information:
Debian Release: 12.2
APT prefers stable
APT policy: (990, 'stable'), (500, 'stable-updates'), (500, 'stable-security'), (500, 'proposed-updates'), (100, 'bookworm-fasttrack'), (100, 'bookworm-backports-staging')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 6.5.3 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8), LANGUAGE=en_AU:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages linux-image-amd64 depends on:
ii linux-image-6.1.0-13-amd64 6.1.55-1
ii linux-image-6.1.0-13-amd64 6.5.0-0
linux-image-amd64 recommends no packages.
linux-image-amd64 suggests no packages.
-- no debconf information
The following script uses hp_wmi to switch between Laptop and Tablet modes.
It also confines the touchscreen to the laptop screen, rotates and redraws
the desktop when required and turns the pen into a mouse.
~/bin/xautorotate.sh
#!/bin/bash
#
# This script enables latop/tablet switching on 2 in 1 devices running
# The Mate or Gnome desktops
#
# Copyright (C) 2023 Haakon McKay hagar@aussiebroadband.com.au
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# Autostart it on login
#
# Requires -
# Kernel module hp_wmi (for HP models)
# xrandr
# udevadm
# xinput
# monitor-sensor
# onboard
#
# 2 files in - /etc/acpi/events/ (for HP models)
######################################
# # /etc/acpi/events/hp-x360-tablet
# event=Type: 5 Code: 1 Value: 1
# action=/etc/acpi/tablet.sh
######################################
# # /etc/acpi/events/hp-x360-laptop
# event=Type: 5 Code: 1 Value: 0
# action=/etc/acpi/laptop.sh
######################################
#
#
# The screen connected to the touchscreen
#
#TD="eDP-1"
TD=`xrandr --listmonitors | grep "^ *0:" | sed -e "s/.* //"`
#
# Find the touchscreen
#
function get-touchy ()
{
NAME=""
TOUCH=false
udevadm info --export-db | while read X
do
case "x${X}"
in
"x") if ${TOUCH} -o ${DISP}
then
test "x${NAME}" != "x" && echo "${NAME}"
fi
NAME=""
TOUCH=false
;;
"xE: NAME="* ) NAME="${X##E: NAME=\"}"
NAME="${NAME%%\"}"
;;
"xE: ID_INPUT_TOUCHSCREEN=1" ) TOUCH=true
;;
esac
done
}
TS="`get-touchy`"
TSP="${TS} Stylus Pen"
TSE="${TS} Stylus Eraser"
function check_inputs ()
{
declare -A PENS
while true
do
while read X
do
F=0
FL=${#PENS[*]}
for (( x=0 ; x<${FL} ; x++))
do
if test "${PENS[${x}]}" = "${X}"
then
F=1
break
fi
done
if test ${F} -eq 0
then
PENS[${FL}]="${X}"
[[ "${X}" =~ "Pen" ]] && echo "Found: Pen: ${X}"
[[ "${X}" =~ "Eraser" ]] && echo "Found: Eraser: ${X}"
fi
done <<EOF
`xinput -list --name-only | grep -E "Pen|Eraser"`
EOF
sleep 0.5
done
}
function check_monitors ()
{
MON=0
while true
do
X=`xrandr | grep -c " connected"`
if ! test ${X} -eq ${MON}
then
MON=${X}
echo "Connected Monitors: ${X}"
fi
sleep 0.5
done
}
function check_tilt ()
{
xinput test "ACPI Virtual Keyboard Device" | while read X
do
case "$X"
in
"key release 203") echo "Tablet Mode" ;;
"key release 204") echo "Laptop Mode" ;;
esac
done
}
function run_em ()
{
check_inputs &
check_tilt &
check_monitors &
monitor-sensor 2>/dev/null
}
function killem ()
{
kill $(jobs -p) 2>/dev/null
}
trap killem EXIT SIGQUIT SIGKILL SIGABRT
#
# Make sure the touchpad is restricted to the correct display
#
xinput map-to-output "${TS}" "${TD}"
#
# Set the lock screen keyboard
#
case "${XDG_CURRENT_DESKTOP}"
in
MATE)
gsettings set org.mate.screensaver embedded-keyboard-command 'onboard -e'
gsettings set org.mate.screensaver embedded-keyboard-enabled true ;;
GNOME)
gsettings set org.gnome.screensaver embedded-keyboard-command 'onboard -e'
gsettings set org.gnome.screensaver embedded-keyboard-enabled true ;;
esac
#
# Loop through and test for orientation change
#
LORIENTATION=""
run_em | while read X ; do
#
# Find the change and set the flags
#
case $X in
*"orientation: normal"*)
ORIENTATION=normal
RFLAGS="1 0 0 0 1 0 0 0 1" ;;
*"orientation changed: normal"*)
ORIENTATION=normal
RFLAGS="1 0 0 0 1 0 0 0 1" ;;
*"orientation changed: left-up"*)
ORIENTATION=left
RFLAGS="0 -1 1 1 0 0 0 0 1" ;;
*"orientation changed: right-up"*)
ORIENTATION=right
RFLAGS="0 1 0 -1 0 1 0 0 1" ;;
*"orientation changed: bottom-up"*)
ORIENTATION=inverted
RFLAGS="-1 0 1 0 -1 1 0 0 1";;
*"Found: Pen: "*)
xinput set-button-map "${X##*: }" 1 2 ;;
*"Found: Eraser: "*)
xinput set-button-map "${X##*: }" 3 ;;
"Laptop Mode")
gsettings set org.onboard.icon-palette in-use false
dbus-send --type=method_call --print-reply --dest=org.onboard.Onboard \
/org/onboard/Onboard/Keyboard org.onboard.Onboard.Keyboard.Hide \
>/dev/null 2>&1
;;
"Tablet Mode")
dbus-send --type=method_call --print-reply --dest=org.onboard.Onboard \
/org/onboard/Onboard/Keyboard org.onboard.Onboard.Keyboard.Show \
>/dev/null 2>&1
gsettings set org.onboard.icon-palette in-use true
;;
*"Connected Monitors: "*)
#
# Make sure the touchpad is restricted to the correct display
#
xinput | grep "${TS}.*pointer" | sed 's/^.[[:space:]]*.[[:space:]]*//g ; s/[[:space:]]*id=.*//;' \
| while read X
do
xinput map-to-output "${X}" "${TD}"
done
ND=${NT}
case "${XDG_CURRENT_DESKTOP}"
in
MATE)
gsettings set org.mate.background show-desktop-icons true
sleep 0.5
gsettings set org.mate.background show-desktop-icons true ;;
GNOME)
gsettings set org.gnome.desktop.background show-desktop-icons true
sleep 0.5
gsettings set org.gnome.desktop.background show-desktop-icons true ;;
esac ;;
esac
#
# Set the original orientation
#
test "x${LORIENTATION}" = "x" && LORIENTATION="${ORIENTATION}"
#
# Make the change if there is one
#
if test "x${ORIENTATION}" != "x" -a "${LORIENTATION}" != "${ORIENTATION}"
then
#
# Set the last orientation
#
LORIENTATION="${ORIENTATION}"
#
# Rotate the screen Part 1
#
# xrandr --output ${TD} -o ${ORIENTATION}
xrandr --output ${TD} --rotate ${ORIENTATION}
case "${XDG_CURRENT_DESKTOP}"
in
MATE)
gsettings set org.mate.background show-desktop-icons false ;;
GNOME)
gsettings set org.gnome.desktop.background show-desktop-icons false ;;
esac
#
# Set the inputs to the new orientation
#
xinput | grep "${TS}.*pointer" | sed 's/^.[[:space:]]*.[[:space:]]*//g ; s/[[:space:]]*id=.*//;' \
| while read X
do
xinput set-prop "${X}" \
--type=float "Coordinate Transformation Matrix" ${RFLAGS}
done
#
# Reset the background (Mate Hack) Part 2
#
sleep 0.5
case "${XDG_CURRENT_DESKTOP}"
in
MATE)
gsettings set org.mate.background show-desktop-icons false ;;
GNOME)
gsettings set org.gnome.desktop.background show-desktop-icons false ;;
esac
#
# Make sure the touchpad is restricted to the correct display
#
xinput | grep "${TS}.*pointer" | sed 's/^.[[:space:]]*.[[:space:]]*//g ; s/[[:space:]]*id=.*//;' \
| while read X
do
xinput map-to-output "${X}" "${TD}"
done
fi
done
Reply to: