summaryrefslogtreecommitdiffstats
path: root/common/recipes-bsp/formfactor/formfactor/machconfig
diff options
context:
space:
mode:
authorJianxun Zhang <jianxun.zhang@linux.intel.com>2016-06-23 17:05:21 -0700
committerTom Zanussi <tom.zanussi@linux.intel.com>2016-06-24 16:30:25 -0500
commiteaadd02702da260cea0cb0728374ba0216f1336e (patch)
tree1d51f9288822de4dc60ab8aa7f9279100df48bc9 /common/recipes-bsp/formfactor/formfactor/machconfig
parent53f25dc1e2469635ed001eb065db9abeacc7bde2 (diff)
downloadmeta-intel-eaadd02702da260cea0cb0728374ba0216f1336e.tar.gz
formfactor: detect USB HID keyboard and touch screen
The new machconfig probes USB keyboard and touch screen, and then sets HAVE_* variables according to detection. Detectable devices: USB HID keyboards (Generic Desktop) USB HID touch screens (Digitizer) Note: The intention is to have a way to provide initial formfactor settings in a boot procedure. That means supported keyboard and touch screen must be connected before machconfig runs. Any new connection or disconnection won't be detected until machconfig is executed again. Limitation: There could be some USB HID devices presents more than one usage in a single descriptor. We will add support once such device emerges. Some platforms may have _virtual_ devices provided by BIOS. It will cause false detection when they are presented as types we supported. We can add black list logic when it becomes a big concern. Fixes [YOCTO #9205] Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com> Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Diffstat (limited to 'common/recipes-bsp/formfactor/formfactor/machconfig')
-rw-r--r--common/recipes-bsp/formfactor/formfactor/machconfig39
1 files changed, 39 insertions, 0 deletions
diff --git a/common/recipes-bsp/formfactor/formfactor/machconfig b/common/recipes-bsp/formfactor/formfactor/machconfig
new file mode 100644
index 00000000..73695fac
--- /dev/null
+++ b/common/recipes-bsp/formfactor/formfactor/machconfig
@@ -0,0 +1,39 @@
1# Note: superuser permission is required to run usbhid-dump
2# successfully.
3
4# HEX keys are according to the USB HID spec and USB HID usage table
5# We can add more keys as needed in the future.
6
7# This test may not be very accurate, as we only look for the first
8# two lines of a descriptor section. Example:
9#
10# 001:003:000:DESCRIPTOR 1460501386.337809
11# 05 01 09 02 A1 01 09 01 A1 00 05 09 19 01 29 03
12# 15 00 25 01 95 03 75 01 81 02 .. .. .. .. .. ..
13# .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
14#
15# By doing so we eliminate false matches when HEX keys are in the lines
16# in the middle of the whole descriptor section.
17
18if type usbhid-dump &>/dev/null; then
19 if USBHID_DUMP_OUTPUT=$(usbhid-dump -e descriptor 2>/dev/null|grep -A1 DESCRIPTOR); then
20 # checker for generic USB HID keyboard
21 USBHID_KBD_CMD="grep -E '^ 05 01 09 06'"
22
23 # checker for touch screen
24 USBHID_TS_CMD="grep -E '^ 05 0D 09 04'"
25
26 if echo "$USBHID_DUMP_OUTPUT"|eval $USBHID_TS_CMD &>/dev/null; then
27 HAVE_TOUCHSCREEN=1
28 fi
29
30 if echo "$USBHID_DUMP_OUTPUT"|eval $USBHID_KBD_CMD &>/dev/null; then
31 HAVE_KEYBOARD=1
32 else
33 # config script in OE will set HAVE_KEYBOARD=1
34 # if we don't set any value. We have to explicitly
35 # tell it when keyboard is not detected.
36 HAVE_KEYBOARD=0
37 fi
38 fi
39fi