meta-digi-dey: pulseaudio: load HDMI sink on hotplug
When hotplugging the HDMI cable after booting the target, pulseaudio doesn't
load the HDMI sink. This commit fixes this by adding a udev rule and a script
that prompts pulseaudio to detect the HDMI sound card and load its sink, as
well as making it the default one.
If alsa-utils is available, a faulty command is run to load the card without
any audio output. Otherwise, module-udev-detect is unloaded and reloaded.
This is based on commit fca507d316.
https://jira.digi.com/browse/DEL-2327
Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
parent
910b8761f0
commit
3e8887da53
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# hdmi_hotplug.sh
|
||||
#
|
||||
# Copyright (C) 2017 by Digi International Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 as published by
|
||||
# the Free Software Foundation.
|
||||
#
|
||||
#
|
||||
# !Description: HDMI hotplug script 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}"
|
||||
break
|
||||
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
|
||||
if which aplay; then
|
||||
# Run a command that always fails but loads
|
||||
# pulseaudio HDMI sink/card as a side effect
|
||||
aplay / -D "hw:${HDMI_CARD}"
|
||||
else
|
||||
# Unload and reload the detection module
|
||||
pactl unload-module module-udev-detect
|
||||
pactl load-module module-udev-detect tsched=0
|
||||
fi
|
||||
|
||||
# Set HDMI as default sink
|
||||
pactl set-default-sink "$(pactl list sinks | grep -i 'Name:.*hdmi' | cut -d ' ' -f2)"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -3,5 +3,16 @@
|
|||
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
|
||||
|
||||
SRC_URI_append_ccimx6ulsbc = " file://0001-pulseaudio-keep-headphones-volume-in-platforms-witho.patch"
|
||||
SRC_URI_append_ccimx6sbc = " file://hdmi_hotplug.sh"
|
||||
|
||||
do_install_append_ccimx6sbc() {
|
||||
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_
|
||||
}
|
||||
|
||||
PACKAGE_ARCH = "${MACHINE_ARCH}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue