[PATCH 5/5] xfree86: add MatchDMI support in InputClass sections
Daniel Martin
consume.noise at gmail.com
Sat Dec 7 07:48:50 PST 2013
This adds support for MatchDMI entries in InputClass sections.
It can be used to match on DMI identifiers applied to the maschine. This
might be usefull when it's not sufficient or possible to match on device
tags or something similar.
Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
I guess at least the changes to the man-page need some beautifying.
hw/xfree86/common/xf86Xinput.c | 7 +++++++
hw/xfree86/man/xorg.conf.man | 22 ++++++++++++++++++++++
hw/xfree86/parser/InputClass.c | 28 ++++++++++++++++++++++++++++
hw/xfree86/parser/xf86Parser.h | 1 +
hw/xfree86/parser/xf86tokens.h | 1 +
5 files changed, 59 insertions(+)
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 26c03c6..37527d3 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -56,6 +56,7 @@
#include <X11/extensions/XIproto.h>
#include <X11/Xatom.h>
#include "xf86.h"
+#include "xf86_OSlib.h"
#include "xf86Priv.h"
#include "xf86Config.h"
#include "xf86Xinput.h"
@@ -594,6 +595,12 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
return FALSE;
/*
+ * MatchDMI string
+ */
+ if (!xf86DMIMatchToken(&iclass->match_dmi, strcmp))
+ return FALSE;
+
+ /*
* MatchTag string
* See if any of the device's tags match any of the MatchTag tokens.
*/
diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
index 85f9f2e..7528023 100644
--- a/hw/xfree86/man/xorg.conf.man
+++ b/hw/xfree86/man/xorg.conf.man
@@ -1133,6 +1133,28 @@ been set by the config backend or a previous
.B InputClass
section.
.TP 7
+.BI "MatchDMI \*q" matchdmi \*q
+This entry can be used to check if DMI identifiers assigned to the maschine
+match the
+.RI \*q matchdmi \*q.
+.RI \*q matchdmi \*q
+is a key value pair separated by a '|' character:
+.RI \*q key|value \*q.
+Possible keys are
+.B BiosDate,
+.B BiosVendor,
+.B BiosVersion,
+.B BoardName,
+.B BoardVendor,
+.B BoardVersion,
+.B ChassisType,
+.B ChassisVendor,
+.B ChassisVersion,
+.B ProductName,
+.B ProductVersion
+and
+.B SystemVendor.
+.TP 7
.BI "MatchTag \*q" matchtag \*q
This entry can be used to check if tags assigned by the config backend
matches the
diff --git a/hw/xfree86/parser/InputClass.c b/hw/xfree86/parser/InputClass.c
index de6a816..19d70bc 100644
--- a/hw/xfree86/parser/InputClass.c
+++ b/hw/xfree86/parser/InputClass.c
@@ -29,6 +29,7 @@
#include <string.h>
#include "os.h"
+#include "../os-support/xf86_OSlib.h"
#include "xf86Parser.h"
#include "xf86tokens.h"
#include "Configint.h"
@@ -48,6 +49,7 @@ xf86ConfigSymTabRec InputClassTab[] = {
{MATCH_PNPID, "matchpnpid"},
{MATCH_USBID, "matchusbid"},
{MATCH_DRIVER, "matchdriver"},
+ {MATCH_DMI, "matchdmi"},
{MATCH_TAG, "matchtag"},
{MATCH_LAYOUT, "matchlayout"},
{MATCH_IS_KEYBOARD, "matchiskeyboard"},
@@ -78,6 +80,7 @@ add_group_entry(struct xorg_list *head, char **values)
XF86ConfInputClassPtr
xf86parseInputClassSection(void)
{
+ char **tokenized;
int has_ident = FALSE;
int token;
@@ -91,6 +94,7 @@ xf86parseInputClassSection(void)
xorg_list_init(&ptr->match_pnpid);
xorg_list_init(&ptr->match_usbid);
xorg_list_init(&ptr->match_driver);
+ xorg_list_init(&ptr->match_dmi);
xorg_list_init(&ptr->match_tag);
xorg_list_init(&ptr->match_layout);
@@ -168,6 +172,17 @@ xf86parseInputClassSection(void)
xstrtokenize(val.str, TOKEN_SEP));
free(val.str);
break;
+ case MATCH_DMI:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchDMI");
+ tokenized = xstrtokenize(val.str, TOKEN_SEP);
+ if (!tokenized || !tokenized[0] || !tokenized[1])
+ Error("The keyword MatchDMI requires a 'key|value' pair");
+ if (!xf86DMIValidKey(tokenized[0]))
+ Error("Invalid key");
+ add_group_entry(&ptr->match_dmi, tokenized);
+ free(val.str);
+ break;
case MATCH_TAG:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchTag");
@@ -317,6 +332,13 @@ xf86printInputClassSection(FILE * cf, XF86ConfInputClassPtr ptr)
*cur);
fprintf(cf, "\"\n");
}
+ xorg_list_for_each_entry(group, &ptr->match_dmi, entry) {
+ fprintf(cf, "\tMatchDMI \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
xorg_list_for_each_entry(group, &ptr->match_tag, entry) {
fprintf(cf, "\tMatchTag \"");
for (cur = group->values; *cur; cur++)
@@ -410,6 +432,12 @@ xf86freeInputClassList(XF86ConfInputClassPtr ptr)
free(*list);
free(group);
}
+ xorg_list_for_each_entry_safe(group, next, &ptr->match_dmi, entry) {
+ xorg_list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
xorg_list_for_each_entry_safe(group, next, &ptr->match_tag, entry) {
xorg_list_del(&group->entry);
for (list = group->values; *list; list++)
diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
index e7210e8..a665c41 100644
--- a/hw/xfree86/parser/xf86Parser.h
+++ b/hw/xfree86/parser/xf86Parser.h
@@ -313,6 +313,7 @@ typedef struct {
struct xorg_list match_pnpid;
struct xorg_list match_usbid;
struct xorg_list match_driver;
+ struct xorg_list match_dmi;
struct xorg_list match_tag;
struct xorg_list match_layout;
xf86TriState is_keyboard;
diff --git a/hw/xfree86/parser/xf86tokens.h b/hw/xfree86/parser/xf86tokens.h
index f751b7b..921a5b0 100644
--- a/hw/xfree86/parser/xf86tokens.h
+++ b/hw/xfree86/parser/xf86tokens.h
@@ -278,6 +278,7 @@ typedef enum {
MATCH_PNPID,
MATCH_USBID,
MATCH_DRIVER,
+ MATCH_DMI,
MATCH_TAG,
MATCH_LAYOUT,
MATCH_IS_KEYBOARD,
--
1.8.4.2
More information about the xorg-devel
mailing list