"External Kernel module for 2-in-1 hybrid laptop"
It detects according to accelerometers's calibration datas, if the laptop is in tablet position. Consequently, it disables the internal keyboard and trackpad.
Information:
- Built for kernel v4.19.40
- Tested with accelerometers handled by the
kxcjk1013
driver
Build the module with the following command:
$ make KDIR=<path/to/kernel/tree/source>
This is an example:
-
Copy this repository as module directory into the kernel source tree. Let's say into the
drivers/input/
subdirectory. -
Integrate the tabletmod's
Kconfig
file into those of thedrivers/input/
(c.f Kconfig section). Add the following line in to thedrivers/input/Kconfig
file:
source "drivers/input/tabletmod/Kconfig"
- Add this module to the building chain, by adding the following line to
the
drivers/input/Makefile
file:
obj-$(CONFIG_TABLET_MODE) += tabletmod/
- Go to the kernel tree's root and run the
make
command
A Kconfig
file is available if you would like to integrate this module with
the kernel's configuration tree structure
(c.f Documentation/kbuild/kconfig-language.txt).
Once installed, you can run the module as following:
# modprobe tabletmod [debug=1]
The debug
option enables the debugging messages.
Add the module name with its options to the /etc/initramfs-tools/modules
file with the following command:
# echo "tabletmod debug=1" > /etc/initramfs-tools/modules
On Debian system, update the current kernel's initramfs (c.f uname -r
) as following:
# update-initramfs -u
For futher information, read the man page.
The idea is to load laptop drivers automatically (and other
drivers which cannot be autoloaded otherwise), based on the DMI system
identification information of the BIOS.
We use the MODULE_ALIAS(_dmi_)
macro to autoload this module according to a given _dmi_
modalias.
Here is an extract from tabletmod.c where we use the product name (pv
) and the board name (rn
) to identify the "Ordissimo Julia 2" platform. The *
wildcard card means it will match anything. Note that the information are seperated by :
colon character:
[...]
// Platform: Ordissimo Julia 2
MODULE_ALIAS("dmi:bvn*:bvr*:bd*:svn*:pnGeoFlex3:pvr*:rvn*:rnS133AR700:*");
[...]
This is a description of all the fields :
bvn: BIOS Vendor | svn: System Vendor | rvn: Board Vendor | cvn: Chassis Vendor
bvr: BIOS Version | pn: Product Name | rn: Board Name | ct: Chassis Type
bd: BIOS Date | pvr: Product Version | rvr: Board Version | cvr: Chassis Version
The following command prints the complete modalias to match the current platform:
$ cat /sys/devices/virtual/dmi/id/modalias
For instance, the following DMI modalias matchs all profiles leveraging the *
wildcard character:
dmi:bvn*:bvr*:bd*:svn*:pn*:pvr*:rvn*:rn*:rvr*:cvn*:ct*:cvr*
Create a .hwdb
file which will contain the machine's entire modalias to test:
# printf "%s\n FAKE_PROPERTY=ok\n" "<full-modalias>" \
> /lib/udev/hwdb.d/99-tabletmod.hwdb
Update the hardware database with the following command:
# systemd-hwdb update
Verify if the given modalias matchs with existing one:
# systemd-hwdb query '<modalias>'
<modalias>
FAKE_PROPERTY=ok
No output if it doesn't match:
# systemd-hwdb query '<bad_modalias>' (no output if no match)