From 4c17247f4e5e186776903e5ff3effa523e7e5ee2 Mon Sep 17 00:00:00 2001 From: Sandeep Gundlupet Raju Date: Tue, 27 Jun 2023 15:44:36 -0600 Subject: xserver-xorg: Move monitor hotplug rules from meta-petalinux Signed-off-by: Sandeep Gundlupet Raju Signed-off-by: Mark Hatle --- .../xserver-xorg/99-monitor-hotplug.rules | 1 + .../xorg-xserver/xserver-xorg/monitor-hotplug.sh | 50 ++++++++++++++++++++++ .../xorg-xserver/xserver-xorg_%.bbappend | 17 ++++++++ 3 files changed, 68 insertions(+) create mode 100644 meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/99-monitor-hotplug.rules create mode 100755 meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/monitor-hotplug.sh diff --git a/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/99-monitor-hotplug.rules b/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/99-monitor-hotplug.rules new file mode 100644 index 00000000..eeb7d671 --- /dev/null +++ b/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/99-monitor-hotplug.rules @@ -0,0 +1 @@ +ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="/usr/bin/monitor-hotplug.sh" diff --git a/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/monitor-hotplug.sh b/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/monitor-hotplug.sh new file mode 100755 index 00000000..d603082d --- /dev/null +++ b/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/monitor-hotplug.sh @@ -0,0 +1,50 @@ +#! /bin/sh + +# Copyright (C) 2018 Xilinx, Inc. All rights reserved. +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +# +# 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 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. + +# Adapt this script to your needs. + +DEVICES=$(find /sys/class/drm/*/status) + +# inspired by /etc/acpd/lid.sh and the function it sources. + +displaynum=`ls /tmp/.X11-unix/* | sed s#/tmp/.X11-unix/X##` +display=":$displaynum.0" +export DISPLAY=":$displaynum.0" + +# from https://wiki.archlinux.org/index.php/Acpid#Laptop_Monitor_Power_Off +export XAUTHORITY=$(ps -C Xorg -f --no-header | sed -n 's/.*-auth //; s/ -[^ ].*//; p') + +for i in /sys/class/drm/*/*/status ; +do + status=$(cat $i); + connector=${i%/status*}; + connector=${connector#*-}; + if [ "$status" == "disconnected" ]; then + xset dpms force off + elif [ "$status" == "connected" ]; then + xset dpms force on + if [ "$(xrandr | grep '\*')" = "" ]; then + xrandr --output $connector --auto + fi + fi +done diff --git a/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg_%.bbappend b/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg_%.bbappend index 83fd7fa6..a9973eff 100644 --- a/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg_%.bbappend +++ b/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg_%.bbappend @@ -2,3 +2,20 @@ DEFAULT_PACKAGE_ARCH := "${PACKAGE_ARCH}" MALI_PACKAGE_ARCH = "${@'${MACHINE_ARCH}' if d.getVar('PREFERRED_PROVIDER_virtual/libgles1') == 'libmali-xlnx' else '${DEFAULT_PACKAGE_ARCH}'}" PACKAGE_ARCH = "${@bb.utils.contains_any('DEPENDS', 'virtual/libgles1 virtual/libgles2 virtual/egl virtual/libgbm', '${MALI_PACKAGE_ARCH}', '${DEFAULT_PACKAGE_ARCH}', d)}" + +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI += " \ + file://monitor-hotplug.sh \ + file://99-monitor-hotplug.rules \ + " + +do_install:append() { + install -d ${D}${bindir} + install -m 0755 ${WORKDIR}/monitor-hotplug.sh ${D}${bindir} + + install -d ${D}${sysconfdir}/udev/rules.d + install -m 0644 ${WORKDIR}/99-monitor-hotplug.rules ${D}${sysconfdir}/udev/rules.d/local.rules +} + +FILES:${PN} += "${sysconfdir}/udev/rules.d/*" -- cgit v1.2.3-54-g00ecf