summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorendorfina2023-11-12 15:38:43 +0100
committerendorfina2023-11-12 15:43:12 +0100
commitdeaf6c7bff49c3d31b47d0fa55c329ae8bf31cc4 (patch)
tree01eb112f40ff7e75a8c93994493521e2dd0f98df
parent40add07ab86fdef786572757df689c69c22cf9de (diff)
downloadaur-deaf6c7bff49c3d31b47d0fa55c329ae8bf31cc4.tar.gz
Actually update udev.sh and suspend.sh to 5.8
-rw-r--r--PKGBUILD4
-rw-r--r--displaylink-sleep.sh41
-rw-r--r--udev.sh127
3 files changed, 122 insertions, 50 deletions
diff --git a/PKGBUILD b/PKGBUILD
index a6e0e09fead1..a967d1538f47 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -27,10 +27,10 @@ source=(displaylink-driver-${pkgver}.zip::https://www.synaptics.com/sites/defaul
sha256sums=('22c552ead448c80d9e8dd48a842bb511184d07a74180ac76bd89dd144ddda816'
'83167d307d030abc42f2bbe6ad6a23802433cf5d8fab50afb0d519036518f22b'
'2f81fea43332a62b2cf1dd47e56ea01caf1e886bcd16c3f82b18bfe148fb21a9'
- 'dc41ae8a2c287fc50fdda65bad8b0ffd76726f7773c25e1b0c5b7de95cecbdb6'
+ '9c9158746b0f6fd6e85b676df1fc6046085e3f1c78db7c5db05da350da776036'
'530c488fa9b2833ff64611ff2b533f63212a85f8ebed446d5a4d51cf9a52c7ea'
'342e83abfe2a38d5635ea928345e933d2ad127ebd3f7caca476663d4f583684b'
- '8be4ab7616e38f91746bdd3e7fafe9004322a8be8e6722389746df9868d576e0')
+ '9b4609423fd9cfaa8cad8acd086dd6b92cd09182facbb28792affeac1ecc4a45')
prepare() {
chmod +x displaylink-driver-${_pkgfullver}.run
diff --git a/displaylink-sleep.sh b/displaylink-sleep.sh
index b47d5fd2d45d..9ffa6c47f831 100644
--- a/displaylink-sleep.sh
+++ b/displaylink-sleep.sh
@@ -1,7 +1,7 @@
-#!/bin/bash
-# Copyright (c) 2015 - 2016 DisplayLink (UK) Ltd.
+#!/usr/bin/env bash
+# Copyright (c) 2015 - 2019 DisplayLink (UK) Ltd.
-suspend_dlm()
+suspend_displaylink-driver()
{
#flush any bytes in pipe
while read -n 1 -t 1 SUSPEND_RESULT < /tmp/PmMessagesPort_out; do : ; done;
@@ -9,24 +9,47 @@ suspend_dlm()
#suspend DisplayLinkManager
echo "S" > /tmp/PmMessagesPort_in
- if [ -f /tmp/PmMessagesPort_out ]; then
+ if [[ -p /tmp/PmMessagesPort_out ]]; then
#wait until suspend of DisplayLinkManager finish
read -n 1 -t 10 SUSPEND_RESULT < /tmp/PmMessagesPort_out
fi
}
-resume_dlm()
+resume_displaylink-driver()
{
#resume DisplayLinkManager
echo "R" > /tmp/PmMessagesPort_in
}
-case "\$1/\$2" in
+main_systemd()
+{
+ case "$1/$2" in
pre/*)
- suspend_dlm
+ suspend_displaylink-driver
;;
post/*)
- resume_dlm
+ resume_displaylink-driver
;;
-esac
+ esac
+}
+main_pm()
+{
+ case "$1" in
+ suspend|hibernate)
+ suspend_displaylink-driver
+ ;;
+ resume|thaw)
+ resume_displaylink-driver
+ ;;
+ esac
+ true
+}
+
+DIR=$(cd "$(dirname "$0")" && pwd)
+
+if [[ $DIR == *systemd* ]]; then
+ main_systemd "$@"
+elif [[ $DIR == *pm* ]]; then
+ main_pm "$@"
+fi
diff --git a/udev.sh b/udev.sh
index 41869bee9ce1..8efabddcc186 100644
--- a/udev.sh
+++ b/udev.sh
@@ -1,20 +1,24 @@
#!/bin/sh
-# Copyright (c) 2016 DisplayLink (UK) Ltd.
+# Copyright (c) 2016 - 2020 DisplayLink (UK) Ltd.
# File autogenerated by udev-installer.sh script
-get_evdi_dev_count()
+get_displaylink_dev_count()
+{
+ cat /sys/bus/usb/devices/*/idVendor | grep 17e9 | wc -l
+}
+
+get_displaylink_symlink_count()
{
- if [ "$(ls -l /sys/devices/platform/* | grep evdi | wc -l)" = "0" ]; then
+ root=$1
+
+ if [ ! -d "$root/displaylink/by-id" ]; then
echo "0"
return
fi
- cat /sys/devices/platform/evdi.*/drm/card*/card*/status | grep "^connected$" | wc -l
-}
-
-get_displaylink_dev_count()
-{
- cat /sys/bus/usb/devices/*/idVendor | grep 17e9 | wc -l
+ for f in $(find $root/displaylink/by-id -type l -exec realpath {} \; 2> /dev/null); do
+ test -c $f && echo $f;
+ done | wc -l
}
start_displaylink()
@@ -24,56 +28,101 @@ start_displaylink()
fi
}
-try_stop_displaylink()
+stop_displaylink()
{
- if [ "$(get_evdi_dev_count)" = "0" ]; then
- parent_dev_path="$1"
- if [ -d "$parent_dev_path" ]; then
- echo "1"
- return
- fi
-
- if [ "$(get_displaylink_dev_count)" = "0" ]; then
- stop_service
- echo "0"
- return
- fi
+ root=$1
+
+ if [ "$(get_displaylink_symlink_count $root)" = "0" ]; then
+ stop_service
fi
- echo "1"
}
-stop_displaylink()
+remove_dldir_if_empty()
+{
+ root=$1
+ (cd $root; rmdir -p --ignore-fail-on-non-empty displaylink/by-id)
+}
+
+create_displaylink_symlink()
{
- parent_devpath=$(dirname /sys$1)
- retry_num="50" # 5s
- while [ "$(try_stop_displaylink $parent_devpath)" != "0" ] && [ "$retry_num" != "0" ];
- do
- sleep 0.1
- retry_num=$((retry_num-1))
- done
+ root=$1
+ device_id=$2
+ devnode=$3
+
+ mkdir -p $root/displaylink/by-id
+ ln -sf $devnode $root/displaylink/by-id/$device_id
+}
+
+unlink_displaylink_symlink()
+{
+ root=$1
+ devname=$2
+
+ for f in $root/displaylink/by-id/*; do
+ if [ ! -e "$f" ] || ([ -L "$f" ] && [ "$f" -ef "$devname" ]); then
+ unlink "$f"
+ fi
+ done
+ (cd $root; rmdir -p --ignore-fail-on-non-empty displaylink/by-id)
+}
+
+prune_broken_links()
+{
+ root=$1
+
+ dir="$root/displaylink/by-id"
+ find -L "$dir" -name "$dir" -o type d -prune -o -type -l -exec rm {} +
+ remove_dldir_if_empty $root
+}
+
+disable_u1_u2()
+{
+ echo 0 > "/sys$1/../port/usb3_lpm_permit"
}
main()
{
- op=$1
- devpath=$2
- if [ "$op" = "START" ]; then
+ action=$1
+ root=$2
+ devpath=$3
+ devnode=$5
+
+ if [ "$action" = "add" ]; then
+ device_id=$4
+ create_displaylink_symlink $root $device_id $devnode
+ start_displaylink
+ disable_u1_u2 "$devpath"
+ elif [ "$action" = "remove" ]; then
+ devname=$3
+ unlink_displaylink_symlink "$root" "$devname"
+ stop_displaylink "$root"
+ elif [ "$action" = "START" ]; then
start_displaylink
- elif [ "$op" = "STOP" ]; then
- stop_displaylink $devpath
fi
}
start_service()
{
- systemctl start displaylink.service
+ systemctl start displaylink-driver
}
stop_service()
{
- systemctl stop displaylink.service
+ systemctl stop displaylink-driver
}
+if [ "$ACTION" = "add" ] && [ "$#" -ge 3 ]; then
+ main $ACTION $1 $2 $3 $4
+ return 0
+fi
-main $1 $2
+if [ "$ACTION" = "remove" ]; then
+ if [ "$#" -ge 2 ]; then
+ main $ACTION $1 $2 $3
+ return 0
+ else
+ prune_broken_links $root
+ return 0
+ fi
+fi