xorg-x11-server/u_Add-udev-scripts-for-configuration-of-platform-devic.patch
Stefan Dirsch edcd3cf183 Accepting request 935494 from home:tdz:branches:X11:XOrg
[boo1193250] Add support for various platform devices

 * Fix SEGFAULT when parsing busid
 * Support configuration files under /run
 * Add udev rules for configuration of platform (e.g., simple-framebuffer)
   and HyperV devices
 * Remove current simpledrm hack from X server

OBS-URL: https://build.opensuse.org/request/show/935494
OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/xorg-x11-server?expand=0&rev=808
2021-12-03 16:28:10 +00:00

157 lines
5.9 KiB
Diff

From edc3e2e465ff1423e7c6ba217bee78a0e0b60f0e Mon Sep 17 00:00:00 2001
From: Thomas Zimmermann <tzimmermann@suse.de>
Date: Tue, 2 Nov 2021 14:29:08 +0100
Subject: Add udev scripts for configuration of platform devices
Generate configuration files for platform devices from udev rules
as X does not support auto-configuration. Implement support for
platform devices, such as simple-frambuffer, on top.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
.../os-support/linux/99-xorg-sysfs.rules | 29 +++++++
hw/xfree86/os-support/linux/Makefile.am | 5 ++
hw/xfree86/os-support/linux/x11sysfsconf | 81 +++++++++++++++++++
3 files changed, 115 insertions(+)
create mode 100644 hw/xfree86/os-support/linux/99-xorg-sysfs.rules
create mode 100644 hw/xfree86/os-support/linux/x11sysfsconf
diff --git a/hw/xfree86/os-support/linux/99-xorg-sysfs.rules b/hw/xfree86/os-support/linux/99-xorg-sysfs.rules
new file mode 100644
index 000000000..940d18ef5
--- /dev/null
+++ b/hw/xfree86/os-support/linux/99-xorg-sysfs.rules
@@ -0,0 +1,29 @@
+#
+# Copyright © 2021 SUSE LINUX GmbH.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+# DRM graphics devices on the platform bus.
+ACTION=="add|remove", \
+ KERNEL=="card[0-9]", \
+ SUBSYSTEM=="drm", \
+ SUBSYSTEMS=="platform", \
+ RUN+="/usr/sbin/x11sysfsconf $env{ACTION} $env{DEVPATH}"
diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am
index 4392fe8d4..6c7b8aa09 100644
--- a/hw/xfree86/os-support/linux/Makefile.am
+++ b/hw/xfree86/os-support/linux/Makefile.am
@@ -42,3 +42,8 @@ liblinux_la_SOURCES = linux.h lnx_init.c lnx_video.c \
AM_CFLAGS = -DHAVE_SYSV_IPC $(DIX_CFLAGS) $(XORG_CFLAGS) $(PLATFORM_DEFINES)
AM_CPPFLAGS = $(XORG_INCS) $(PLATFORM_INCLUDES) $(LIBDRM_CFLAGS)
+
+dist_sbin_SCRIPTS = x11sysfsconf
+
+udevrulesdir = @sysconfdir@/udev/rules.d
+dist_udevrules_DATA = 99-xorg-sysfs.rules
diff --git a/hw/xfree86/os-support/linux/x11sysfsconf b/hw/xfree86/os-support/linux/x11sysfsconf
new file mode 100644
index 000000000..f5eabde6e
--- /dev/null
+++ b/hw/xfree86/os-support/linux/x11sysfsconf
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+#
+# Copyright © 2021 SUSE LINUX GmbH.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+#
+# x11sysfsconf - generate X11 configuration files from sysfs device paths
+#
+# x11sysfsconf adds or removes X11 configuration files from sysfs
+# device paths. The generated file contains a Device section with
+# the device's identifier and bus id.
+#
+# Kernel graphics drivers export system framebuffers as platform
+# devices, which cannot be configured by X automatically. Instead
+# X expects a configuration file with the device's identifier and
+# bus id. This script, plus a udev rule, automatically creates and
+# removes rsp configuration for each system framebuffer.
+#
+# Besides system framebuffers, several other kernel graphics drivers
+# operate on platform device. Examples are hyperv_drm and several
+# embedded ARM SoCs. x11sysfsconf can generate X11 configuration for
+# all such cases.
+#
+# The configuration file lives under /run, so that it's being removed
+# upon reboots.
+#
+# Copy this script to /usr/sbin and add the rsp udev rule to
+# /etc/udev/rules.d.
+#
+# TODO:
+# - Support non-platform devices, if any
+# - Improve error handling
+#
+
+set -e
+
+filename=`basename $2`
+
+runconfpath="/run/X11/xorg.conf.d"
+confname="10-$filename.conf"
+tempname="$confname.$$"
+
+abs_runconfpath="$runconfpath/$confname"
+abs_temppath="$runconfpath/$tempname"
+
+case $1 in
+"add")
+ mkdir -p $runconfpath
+ echo -e "Section \"Device\"\n"\
+ "\tIdentifier \"Device-$filename\"\n"\
+ "\tBusID \"platform:/sys$2\"\n"\
+ "EndSection" > $abs_temppath
+ mv $abs_temppath $abs_runconfpath
+ ;;
+"remove")
+ rm -f $abs_runconfpath
+ ;;
+*)
+ echo "Usage: $0 [add|remove] DEVPATH"
+ ;;
+esac
--
2.34.0