meta-digi-dey: pulseaudio: improve HDMI hotplug script
The HDMI hotplug script required alsa-utils to be installed in order to work. This commit avoids this by adding a recipe for a small binary that replaces aplay in the script. https://jira.digi.com/browse/DEL-3482 Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
parent
0cd1c803ce
commit
73ebf262de
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Copyright (C) 2017 Digi International.
|
||||||
|
|
||||||
|
SUMMARY = "DEY sound card detection app"
|
||||||
|
SECTION = "multimedia"
|
||||||
|
LICENSE = "MPL-2.0"
|
||||||
|
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
|
||||||
|
|
||||||
|
DEPENDS = "alsa-lib"
|
||||||
|
|
||||||
|
SRC_URI = "file://card-detect.c"
|
||||||
|
|
||||||
|
S = "${WORKDIR}"
|
||||||
|
|
||||||
|
do_compile() {
|
||||||
|
${CC} -O2 -Wall card-detect.c -o card-detect -lasound
|
||||||
|
}
|
||||||
|
|
||||||
|
do_install() {
|
||||||
|
install -d ${D}${bindir}
|
||||||
|
install -m 0755 card-detect ${D}${bindir}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017 Digi International Inc.
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <alsa/asoundlib.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int len, ret = EXIT_SUCCESS;
|
||||||
|
snd_pcm_t *handle;
|
||||||
|
char *device;
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
printf("Usage: %s [CARD NUMBER]\n", argv[0]);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = strlen("hw:") + strlen(argv[1]) + 1;
|
||||||
|
device = calloc(1, len);
|
||||||
|
snprintf(device, len, "hw:%s", argv[1]);
|
||||||
|
|
||||||
|
/* Open the PCM-device in playback mode */
|
||||||
|
if (snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0) < 0) {
|
||||||
|
printf("Could't open PCM '%s'\n", device);
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
|
} else {
|
||||||
|
printf("Device %s opened successfully\n", device);
|
||||||
|
snd_pcm_close(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(device);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
@ -22,3 +22,5 @@ RDEPENDS_${PN} = "\
|
||||||
alsa-states \
|
alsa-states \
|
||||||
${ALSA_UTILS_PKGS} \
|
${ALSA_UTILS_PKGS} \
|
||||||
"
|
"
|
||||||
|
|
||||||
|
RDEPENDS_${PN}_append_ccimx6sbc = " card-detect"
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,7 @@ done
|
||||||
# HDMI audio sink from ALSA
|
# HDMI audio sink from ALSA
|
||||||
if [ "${EVENT}" = "plugin" ]; then
|
if [ "${EVENT}" = "plugin" ]; then
|
||||||
if ! pactl list sinks | grep -qs "imx-hdmi-soc"; then
|
if ! pactl list sinks | grep -qs "imx-hdmi-soc"; then
|
||||||
if which aplay; then
|
card-detect "${HDMI_CARD}"
|
||||||
# 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
|
# Set HDMI as default sink
|
||||||
pactl set-default-sink "$(pactl list sinks | grep -i 'Name:.*hdmi' | cut -d ' ' -f2)"
|
pactl set-default-sink "$(pactl list sinks | grep -i 'Name:.*hdmi' | cut -d ' ' -f2)"
|
||||||
|
|
|
||||||
|
|
@ -16,3 +16,6 @@ do_install_append_ccimx6sbc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
PACKAGE_ARCH = "${MACHINE_ARCH}"
|
PACKAGE_ARCH = "${MACHINE_ARCH}"
|
||||||
|
|
||||||
|
# The card-detect binary is only necessary for the HDMI hotplug to work on the ccimx6sbc
|
||||||
|
RDEPENDS_${PN}_append_ccimx6sbc = " card-detect"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue