Re: keymap rule selection for non-DMI platforms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i wrote:
 > hi --
 > 
 > OLPC's latest laptop (the 1.75 model) is ARM-based.  this means the
 > current keymap rule in rules.d/95-keymap.rules:
 > 
 >  ENV{DMI_VENDOR}=="OLPC", ATTR{[dmi/id]product_name}=="XO", \
 >  	RUN+="keymap $name olpc-xo"
 > 
 > won't trigger -- there's no DMI information.
 > 
 > any thoughts on how non-PC hardware should be identifying itself
 > to udev?  are there other examples of how this might be done?
 > 
 > i'm sure we could come up with something, based on examining some
 > other sysfs attribute, or perhaps running a command which identifies
 > our laptop(s), but i suspect this issue has come up before.
 > 

since my initial query was met with such enthusiastic silence :-),
i've decided to try another approach.  attached is a (very tentative)
patch that supports our non-DMI laptop using a familiy-identifying
attribute found in /proc/device-tree.

essentially it adds a utility (currently in shell, but which will
trivially turn into C) that facilitates forming environment keys from
device-tree nodes.  this is then used in 95-keymap.rules to detect an
XO laptop and apply the right keymap.  the device-tree has always been
under /proc on linux -- it would probably make more sense under /sys,
but i'm not sure about the effort needed for, or the ramifications of,
such a move.

like i said, the attached constitutes a strawman approach.  hopefully
it will generate some thumbs, either up or down.

paul


commit ec4edb170cde845c7f710d98d7aceab2db729c53
Author: Paul Fox <pgf@xxxxxxxxxx>
Date:   Tue Aug 16 14:26:55 2011 -0400

    tentative support for using device-tree attributes to identify a platform
    
    the new script device-tree-val is used in 95-keymap.rules to identify
    an OLPC XO laptop, based on the contents of /proc/device-tree/compatible

diff --git a/extras/device-tree/device-tree-val b/extras/device-tree/device-tree-val
new file mode 100644
index 0000000..46c884a
--- /dev/null
+++ b/extras/device-tree/device-tree-val
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+dtree=/proc/device-tree
+
+usage()
+{
+	echo ${0##*/} key path >&2
+	exit 1
+}
+
+test $# = 2 || usage
+
+key="$1"
+path="$2"
+
+# 2nd arg must exist and be readable
+: < $dtree/$path || exit 1
+
+echo $key=$(cat $dtree/$path)
+
+
diff --git a/extras/keymap/95-keymap.rules b/extras/keymap/95-keymap.rules
index 0d9b771..36d5d19 100644
--- a/extras/keymap/95-keymap.rules
+++ b/extras/keymap/95-keymap.rules
@@ -40,7 +40,7 @@ GOTO="keyboard_end"
 LABEL="keyboard_modulecheck"
 
 ENV{DMI_VENDOR}="$attr{[dmi/id]sys_vendor}"
-ENV{DMI_VENDOR}=="", GOTO="keyboard_end"
+ENV{DMI_VENDOR}=="", GOTO="keyboard_devicetree"
 
 ENV{DMI_VENDOR}=="IBM*", KERNELS=="input*", ATTRS{name}=="ThinkPad Extra Buttons", RUN+="keymap $name module-ibm"
 ENV{DMI_VENDOR}=="LENOVO*", KERNELS=="input*", ATTRS{name}=="ThinkPad Extra Buttons", RUN+="keymap $name module-lenovo"
@@ -156,5 +156,11 @@ ENV{DMI_VENDOR}=="Everex", ATTR{[dmi/id]product_name}=="XT5000*", RUN+="keymap $
 ENV{DMI_VENDOR}=="COMPAL", ATTR{[dmi/id]product_name}=="HEL80I", RUN+="keymap $name 0x84 wlan"
 
 ENV{DMI_VENDOR}=="OLPC", ATTR{[dmi/id]product_name}=="XO", RUN+="keymap $name olpc-xo"
+GOTO="keyboard_end"
+
+LABEL="keyboard_devicetree"
+
+IMPORT{command}="device-tree-val DEVTREE_COMPAT compatible"
+ENV{DEVTREE_COMPAT}=="olpc,xo-1*", RUN+="keymap $name olpc-xo"
 
 LABEL="keyboard_end"
=---------------------
 paul fox, pgf@xxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux