meta-nuc: init script for configuring HDMI audio

Provide an init script to check at boot time which HDMI port is connected
and configure the default ALSA audio out to that port.

Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
This commit is contained in:
Nitin A Kamble 2012-12-11 16:00:21 -08:00 committed by Tom Zanussi
parent a2d990eaad
commit 773a71c667
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,28 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Configure ALSA audio output to the connected HDMI port
### END INIT INFO
#
# If both HDMI ports are connected then use HDMI0 for default ALSA audio out..
ALSA_CONF_FILE="/etc/asound.conf"
HDMI0_STATUS_FILE="/sys/class/drm/card0-HDMI-A-1/status"
HDMI1_STATUS_FILE="/sys/class/drm/card0-HDMI-A-2/status"
HDMI0_ALSA_CONF="hw:0,3"
HDMI1_ALSA_CONF="hw:0,7"
if [ -f "${HDMI0_STATUS_FILE}" ] && [ "`cat ${HDMI0_STATUS_FILE}`" == "connected" ]
then
sed -i "s/pcm *\"hw:[0-9]*,[0-9]*\"/pcm \"${HDMI0_ALSA_CONF}\"/" ${ALSA_CONF_FILE}
elif [ -f "${HDMI1_STATUS_FILE}" ] && [ "`cat ${HDMI1_STATUS_FILE}`" == "connected" ]
then
sed -i "s/pcm \"hw:[0-9]*,[0-9]*\"/pcm \"${HDMI1_ALSA_CONF}\"/" ${ALSA_CONF_FILE}
fi

View File

@ -0,0 +1,10 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://hdmi_port_audio.sh"
PR .= ".1"
do_install_append() {
install -m 0755 ${WORKDIR}/hdmi_port_audio.sh ${D}${sysconfdir}/init.d
ln -sf ../init.d/hdmi_port_audio.sh ${D}${sysconfdir}/rcS.d/S66hdmi_port_audio.sh
}