meta-digi-dey: pulseaudio: add HDMI audio sink on hotplug

This patch adds a udev rule and a script to detect HDMI hotplug and create
the HDMI audio pulseaudio sink if needed (that is, if the system was
booted with no HDMI cable plugged).

https://jira.digi.com/browse/DEL-2327

Signed-off-by: Jose Diaz de Grenu de Pedro <Jose.DiazdeGrenudePedro@digi.com>
This commit is contained in:
Jose Diaz de Grenu de Pedro 2016-03-08 18:36:49 +01:00
parent 8260fb9226
commit fca507d316
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,18 @@
#!/bin/sh
#
# Called from udev on HDMI plug/unplug event
# Find HDMI card number
for card in /sys/class/sound/card*; do
if readlink ${card}/device | grep -qs hdmi; then
HDMI_CARD="${card##/sys/class/sound/card}"
fi
done
# On HDMI plugin event, if the sink has not been loaded yet, load the
# HDMI audio sink from ALSA
if [ "${EVENT}" = "plugin" ]; then
if ! pactl list sinks | grep -qs "imx-hdmi-soc"; then
pactl load-module module-alsa-sink device=hw:${HDMI_CARD}
fi
fi

View File

@ -1,2 +1,16 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
SRC_URI += "file://hdmi_hotplug.sh"
# Do not include module-udev-detect so that module-detect is used instead
RDEPENDS_pulseaudio-server_remove = "pulseaudio-module-udev-detect"
do_install_append() {
install -d ${D}${sysconfdir}/udev/scripts
install -m 0755 ${WORKDIR}/hdmi_hotplug.sh ${D}${sysconfdir}/udev/scripts
cat >> ${D}${base_libdir}/udev/rules.d/90-pulseaudio.rules <<-_EOL_
SUBSYSTEM=="platform", KERNEL=="*hdmi_video", ACTION=="change", RUN+="/etc/udev/scripts/hdmi_hotplug.sh"
_EOL_
}