summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2021-04-07 11:49:22 +0900
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>2021-04-07 11:49:22 +0900
commitf125f8b1ba74737a3ed6802f679df6c4a4b5ceaa (patch)
tree3e75726b36ba50f20ff774fc2d948e784fe9d93b
parent34fde9f898f63096262d95c61d75db85dabe6fe4 (diff)
downloadsystemd-f125f8b1ba74737a3ed6802f679df6c4a4b5ceaa.tar.gz
hwdb: add hardware database for unit of IEEE 1394
Current udev rules configures group owner of firewire character device to video group, corresponding to nodes in IEEE 1394 in below cases: 1.the node with any unit for any minor version of IIDC version 1 specification defined by 1394 Trading Association 2.the node with any unit for specification defined by Point Grey Research 3.the node with any unit for AV/C device v1.0 defined by 1394 Trading Association 4.the node with any unit for vendor-unique protocol defined by 1394 Trading Association Nevertheless, case 3 and 4 can cover the node with any unit for audio function as well. In the cases, it's convenient to assign audio group. Additionally, some nodes are known to have layout different from the specification defined by 1394 Trading Association. In the case, it's required to add rules specific to them. Furthermore, some nodes have no fields for vendor name and model name in configuration ROM. In the case, it's required to add entries to hardware database for users convenience. For the above reasons, this commit adds rules to use information in hardware database for known units in IEEE 1394. One database entry corresponds to one unit. Two types of key are used to match the unit; customized key from node context, kernel modalias of unit context. The entry has the type of function, at least. Supplementally, it has vendor and model names. For your information, below statements with Python pyparsing module are expected to parse all of the custom key and module alias in the list: ``` subsystem_prefix = pp.Literal('ieee1394:').suppress() hex_to_int = lambda a: int(a[0], 16) node_prefix = pp.Literal('node:').suppress() prefixed_lower_hex = pp.Combine(pp.Literal('0x') + pp.Word(pp.srange('[a-z0-9]'), exact=6)).setParseAction(hex_to_int) ven_in_node = pp.dictOf(pp.Literal('ven'), prefixed_lower_hex) mo_in_node = pp.dictOf(pp.Literal('mo'), prefixed_lower_hex) unit_in_node = pp.Group(prefixed_lower_hex + pp.Literal(':').suppress() + prefixed_lower_hex) units_in_node = pp.Group(pp.Literal('units') + pp.ZeroOrMore(pp.Literal('*')).suppress() + unit_in_node + pp.ZeroOrMore(pp.Literal('*')).suppress()) node_parser = subsystem_prefix + node_prefix + ven_in_node + pp.Optional(mo_in_node) + units_in_node higher_hex = pp.Word(pp.srange('[A-Z0-9]'), exact=8).setParseAction(hex_to_int) ven_in_unit = pp.dictOf(pp.Literal('ven'), higher_hex) mo_literal_in_unit = pp.dictOf(pp.Literal('mo'), higher_hex) mo_in_unit = pp.dictOf(pp.Literal('mo'), higher_hex ^ pp.Literal('*')) sp_in_unit = pp.dictOf(pp.Literal('sp'), higher_hex) ver_in_unit = pp.dictOf(pp.Literal('ver'), higher_hex) unit_parser = subsystem_prefix + ven_in_unit + mo_in_unit + sp_in_unit + ver_in_unit key_parser = node_parser ^ unit_parser ``` Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r--hwdb.d/80-ieee1394-unit-function.hwdb38
-rw-r--r--hwdb.d/meson.build1
-rw-r--r--rules.d/50-udev-default.rules.in10
-rw-r--r--src/login/70-uaccess.rules.m44
4 files changed, 53 insertions, 0 deletions
diff --git a/hwdb.d/80-ieee1394-unit-function.hwdb b/hwdb.d/80-ieee1394-unit-function.hwdb
new file mode 100644
index 0000000000..3cfdbb8b2c
--- /dev/null
+++ b/hwdb.d/80-ieee1394-unit-function.hwdb
@@ -0,0 +1,38 @@
+# This file is part of systemd.
+
+# Description
+#
+# Each node on IEEE 1394 bus has configuration ROM with information for identification. Although the
+# typical content of configuration ROM is defined by 1394 Trading Association, many nodes have own
+# quirks. This database includes supplemental information to unit in the node.
+
+# Convention
+#
+# One entry has two keys. One is customized key to match a node. Another is for kernel alias to
+# match an unit included in the node.
+#
+# The customized key has two formats according to whether the node has model attribute:
+# - ven0x000000mo0x000000units0x000000:0x000000
+# - ven0x000000units0x000000:0x000000
+#
+# Even when the node has multiple units, the entry should match to one of the units. In the case,
+# the customized key should have wild pattern for units field:
+# - ven0x000000mo0x000000units*0x000000:0x000000*
+# - ven0x000000units*0x000000:0x000000*
+#
+# The hexadecimal digits part of the customized key should be lower-case. Linux FireWire subsystem
+# uses lower-case value for attributes of sysfs node, and systemd-hwdb parses the custom key by
+# case-sensitive way. On the other hand, it parses kernel alias by case-insensitive way.
+#
+# The entry should have some of IEEE1394_UNIT_FUNCTION_XXX environment variables to express function
+# of the unit. The variables are used to decide group owner of special file for character device
+# corresponding to node including the unit. At present, below variables are supported:
+# - IEEE1394_UNIT_FUNCTION_MIDI
+# - For any unit to process MIDI messages. For example, the unit includes AV/C music subunit.
+# - IEEE1394_UNIT_FUNCTION_AUDIO
+# - For any unit to process audio signal. For example, the unit includes AV/C audio subunit.
+# - IEEE1394_UNIT_FUNCTION_VIDEO
+# - For any unit to process video signal.
+#
+# Additionally, ID_VENDOR_FROM_DATABASE and ID_MODEL_FROM_DATABASE environment variables are
+# preferable.
diff --git a/hwdb.d/meson.build b/hwdb.d/meson.build
index 7221a1ae9f..6a16268816 100644
--- a/hwdb.d/meson.build
+++ b/hwdb.d/meson.build
@@ -30,6 +30,7 @@ hwdb_files_test = files('''
70-mouse.hwdb
70-pointingstick.hwdb
70-touchpad.hwdb
+ 80-ieee1394-unit-function.hwdb
'''.split())
if conf.get('ENABLE_HWDB') == 1
diff --git a/rules.d/50-udev-default.rules.in b/rules.d/50-udev-default.rules.in
index edfa8bb107..dabde06dde 100644
--- a/rules.d/50-udev-default.rules.in
+++ b/rules.d/50-udev-default.rules.in
@@ -54,6 +54,16 @@ SUBSYSTEM=="firewire", ATTR{units}=="*0x00b09d:0x00010*", GROUP="video"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x010001*", GROUP="video"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x014001*", GROUP="video"
+SUBSYSTEM=="firewire", TEST=="units", TEST=="model", \
+ IMPORT{builtin}="hwdb 'ieee1394:node:ven$attr{vendor}mo$attr{model}units$attr{units}'"
+
+SUBSYSTEM=="firewire", TEST=="units", TEST!="model", \
+ IMPORT{builtin}="hwdb 'ieee1394:node:ven$attr{vendor}units$attr{units}'"
+
+SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_MIDI}=="1", GROUP="audio"
+SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_AUDIO}=="1", GROUP="audio"
+SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_VIDEO}=="1", GROUP="video"
+
KERNEL=="parport[0-9]*", GROUP="lp"
SUBSYSTEM=="printer", KERNEL=="lp*", GROUP="lp"
SUBSYSTEM=="ppdev", GROUP="lp"
diff --git a/src/login/70-uaccess.rules.m4 b/src/login/70-uaccess.rules.m4
index 45e4adfa0f..f621c684dd 100644
--- a/src/login/70-uaccess.rules.m4
+++ b/src/login/70-uaccess.rules.m4
@@ -44,6 +44,10 @@ SUBSYSTEM=="firewire", ATTR{units}=="*0x00b09d:0x00010*", TAG+="uaccess"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x010001*", TAG+="uaccess"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x014001*", TAG+="uaccess"
+SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_MIDI}=="1", TAG+="uaccess"
+SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_AUDIO}=="1", TAG+="uaccess"
+SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_VIDEO}=="1", TAG+="uaccess"
+
# DRI video devices
SUBSYSTEM=="drm", KERNEL=="card*", TAG+="uaccess"
m4_ifdef(`GROUP_RENDER_UACCESS',``