diff --git a/meta-digi-dey/recipes-multimedia/pulseaudio/pulseaudio/hdmi_hotplug.sh b/meta-digi-dey/recipes-multimedia/pulseaudio/pulseaudio/hdmi_hotplug.sh new file mode 100644 index 000000000..78a29786d --- /dev/null +++ b/meta-digi-dey/recipes-multimedia/pulseaudio/pulseaudio/hdmi_hotplug.sh @@ -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 + diff --git a/meta-digi-dey/recipes-multimedia/pulseaudio/pulseaudio_%.bbappend b/meta-digi-dey/recipes-multimedia/pulseaudio/pulseaudio_%.bbappend index 3ee26fa5c..f83abe9dd 100644 --- a/meta-digi-dey/recipes-multimedia/pulseaudio/pulseaudio_%.bbappend +++ b/meta-digi-dey/recipes-multimedia/pulseaudio/pulseaudio_%.bbappend @@ -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}"