From: Paul Fox <pgf@laptop.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: keymap rule selection for non-DMI platforms
Date: Tue, 16 Aug 2011 18:54:02 +0000 [thread overview]
Message-ID: <21148.1313520842@foxharp.boston.ma.us> (raw)
In-Reply-To: <3483.1313087020@foxharp.boston.ma.us>
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@laptop.org>
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@laptop.org
next prev parent reply other threads:[~2011-08-16 18:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-11 18:23 keymap rule selection for non-DMI platforms Paul Fox
2011-08-16 18:54 ` Paul Fox [this message]
2011-08-16 19:34 ` Kay Sievers
2011-08-16 20:09 ` Daniel Drake
2011-08-16 20:30 ` Kay Sievers
2011-08-16 20:39 ` Daniel Drake
2011-08-16 20:49 ` Paul Fox
2011-08-16 21:47 ` Greg KH
2011-08-16 22:27 ` Kay Sievers
2011-08-16 22:34 ` Kay Sievers
2011-08-16 22:37 ` Kay Sievers
2011-08-16 22:54 ` Daniel Drake
2011-08-16 23:35 ` Prarit Bhargava
2011-08-17 2:09 ` Karl O. Pinc
2011-08-17 3:32 ` Paul Fox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=21148.1313520842@foxharp.boston.ma.us \
--to=pgf@laptop.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).