Add alsa-state configuration for stm32mp machine

Signed-off-by: Christophe Priouzeau <christophe.priouzeau@st.com>
This commit is contained in:
Christophe Priouzeau 2019-02-04 15:38:02 +01:00
parent acdb06a727
commit ad56767835
7 changed files with 3263 additions and 0 deletions

View File

@ -0,0 +1,79 @@
# Copyright (C) 2018, STMicroelectronics - All Rights Reserved
# Released under the MIT license (see COPYING.MIT for the terms)
SUMMARY = "Alsa scenario files to enable alsa state restoration"
HOMEPAGE = "http://www.alsa-project.org/"
DESCRIPTION = "Alsa Scenario Files - an init script and state files to restore \
sound state at system boot and save it at system shut down."
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
PV = "1.0"
SRC_URI = ""
# Machine generic
SRC_URI_append_stm32mp1 = " \
file://asound-stm32mp157c-ev.conf \
file://asound-stm32mp157c-dk.conf \
\
file://asound-stm32mp157c-ev.state \
file://asound-stm32mp157c-dk.state \
\
file://system-generator-alsa-states \
file://system-generator-alsa-conf \
"
# Machine board specific
SRC_URI_append_stm32mp1-eval = " \
file://asound-stm32mp157c-ev.conf \
file://asound-stm32mp157c-ev.state \
"
SRC_URI_append_stm32mp1-disco = " \
file://asound-stm32mp157c-dk.conf \
file://asound-stm32mp157c-dk.state \
"
S = "${WORKDIR}"
COMPATIBLE_MACHINE = "(stm32mpcommon)"
RDEPENDS_${PN} = "alsa-state"
do_install() {
install -d ${D}${sysconfdir}
install -m 0644 ${WORKDIR}/*.conf ${D}${sysconfdir}/
install -d ${D}/${localstatedir}/lib/alsa
install -m 0644 ${WORKDIR}/*.state ${D}${localstatedir}/lib/alsa
# Enable systemd automatic selection
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
install -d ${D}${systemd_unitdir}/system-generators/
if [ -f ${WORKDIR}/system-generator-alsa-states ]; then
install -m 0755 ${WORKDIR}/system-generator-alsa-states ${D}${systemd_unitdir}/system-generators/
fi
if [ -f ${WORKDIR}/system-generator-alsa-conf ]; then
install -m 0755 ${WORKDIR}/system-generator-alsa-conf ${D}${systemd_unitdir}/system-generators/
fi
fi
}
pkg_postinst_${PN}_stm32mp1-eval() {
if test -z "$D"
then
if test -x ${sbindir}/alsactl
then
${sbindir}/alsactl -f ${localstatedir}/lib/alsa/asound-stm32mp157c-ev.state restore
fi
fi
}
pkg_postinst_${PN}_stm32mp1-disco() {
if test -z "$D"
then
if test -x ${sbindir}/alsactl
then
${sbindir}/alsactl -f ${localstatedir}/lib/alsa/asound-stm32mp157c-dk.state restore
fi
fi
}
FILES_${PN} = "${localstatedir}/lib/alsa/*.state ${systemd_unitdir}/system-generators ${sysconfdir}/*.conf "

View File

@ -0,0 +1,17 @@
pcm.!playback_codec {
type hw
card STM32MP1DK
device 0
}
pcm.!record_codec {
type hw
card STM32MP1DK
device 1
}
pcm.!playback_hdmi {
type hw
card STM32MP1DK
device 2
}

View File

@ -0,0 +1,198 @@
state.STM32MP1DK {
control.1 {
iface MIXER
name 'PCM Playback Volume'
value.0 63
value.1 63
comment {
access 'read write'
type INTEGER
count 2
range '0 - 127'
dbmin -5150
dbmax 1200
dbvalue.0 -2000
dbvalue.1 -2000
}
}
control.2 {
iface MIXER
name 'PCM Playback Switch'
value.0 true
value.1 true
comment {
access 'read write'
type BOOLEAN
count 2
}
}
control.3 {
iface MIXER
name 'Analog Playback Volume'
value.0 204
value.1 204
comment {
access 'read write'
type INTEGER
count 2
range '0 - 228'
dbmin -10200
dbmax 1200
dbvalue.0 0
dbvalue.1 0
}
}
control.4 {
iface MIXER
name 'ADC Mixer Volume'
value.0 103
value.1 103
comment {
access 'read write'
type INTEGER
count 2
range '0 - 127'
dbmin -5150
dbmax 1200
dbvalue.0 0
dbvalue.1 0
}
}
control.5 {
iface MIXER
name 'ADC Mixer Switch'
value.0 false
value.1 false
comment {
access 'read write'
type BOOLEAN
count 2
}
}
control.6 {
iface MIXER
name 'Playback Deemphasis Switch'
value false
comment {
access 'read write'
type BOOLEAN
count 1
}
}
control.7 {
iface MIXER
name 'Auto-Mute Switch'
value true
comment {
access 'read write'
type BOOLEAN
count 1
}
}
control.8 {
iface MIXER
name 'Soft Ramp Switch'
value false
comment {
access 'read write'
type BOOLEAN
count 1
}
}
control.9 {
iface MIXER
name 'Zero Cross Switch'
value 0
comment {
access 'read write'
type INTEGER
count 1
range '0 - 0'
}
}
control.10 {
iface MIXER
name 'Mic Boost Volume'
value.0 1
value.1 1
comment {
access 'read write'
type INTEGER
count 2
range '0 - 1'
dbmin 1600
dbmax 3200
dbvalue.0 3200
dbvalue.1 3200
}
}
control.11 {
iface MIXER
name 'Bass Volume'
value 7
comment {
access 'read write'
type INTEGER
count 1
range '0 - 15'
dbmin -1050
dbmax 1200
dbvalue.0 0
}
}
control.12 {
iface MIXER
name 'Treble Volume'
value 7
comment {
access 'read write'
type INTEGER
count 1
range '0 - 15'
dbmin -1050
dbmax 1200
dbvalue.0 0
}
}
control.13 {
iface MIXER
name 'PCM channel mixer'
value 'L R'
comment {
access 'read write'
type ENUMERATED
count 1
item.0 'L R'
item.1 L+R
item.2 'R L'
}
}
control.14 {
iface MIXER
name 'PGA-ADC Mux Left'
value 'MIC+preamp Left'
comment {
access 'read write'
type ENUMERATED
count 1
item.0 'AIN1 Left'
item.1 'AIN2 Left'
item.2 'MIC Left'
item.3 'MIC+preamp Left'
}
}
control.15 {
iface MIXER
name 'PGA-ADC Mux Right'
value 'AIN1 Right'
comment {
access 'read write'
type ENUMERATED
count 1
item.0 'AIN1 Right'
item.1 'AIN2 Right'
item.2 'MIC Right'
item.3 'MIC+preamp Right'
}
}
}

View File

@ -0,0 +1,47 @@
pcm.!playback_codec {
type hw
card STM32MP1EV
device 0
}
pcm.!record_codec {
type hw
card STM32MP1EV
device 1
}
pcm.!playback_spdif {
type hw
card STM32MP1EV
device 2
}
pcm.!record_spdif {
type hw
card STM32MP1EV
device 3
}
pcm.!record_dfsdm0 {
type hw
card STM32MP1EV
device 4
}
pcm.!record_dfsdm1 {
type hw
card STM32MP1EV
device 5
}
pcm.!record_dfsdm2 {
type hw
card STM32MP1EV
device 6
}
pcm.!record_dfsdm3 {
type hw
card STM32MP1EV
device 7
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
#!/bin/sh
# Script which detect automaticaly the alsa-conf file to put
# in place in function of board on which the script are executed.
#
# This script are use with systemd-generators
# see man for more information or
# https://www.freedesktop.org/software/systemd/man/systemd.generator.html
#
# How to debug:
# mkdir /tmp/normal-dir /tmp/early-dir /tmp/late-dir
# SYSTEMD_LOG_LEVEL=debug /lib/systemd/system-generators/system-generator-alsa-conf \
# /tmp/normal-dir /tmp/early-dir /tmp/late-dir
# find /tmp/normal-dir /tmp/early-dir /tmp/late-dir
#
#
function debug_print() {
if `echo $SYSTEMD_LOG_LEVEL |grep -q debug` ;
then
echo "[DEBUG] $@"
fi
}
#
# Main
#
if [ ! -d /proc/device-tree/ ];
then
debug_print "Proc Device tree are not available, Could not detect on which board we are"
exit 1
fi
if [ -e /etc/asound.conf ];
then
LINE=`cat /etc/asound.conf | wc -l`
if [ $LINE -lt 3 ];
then
# dummy asound.conf file contains only one comment
debug_print "remove previous dummy asound.conf file"
rm /etc/asound.conf
else
debug_print "asound.conf file already configured"
exit 0
fi
fi
# get the name file available for alsa-conf
ALSA_CONF_FILES=`ls -1 /etc/asound-*`
for f in $ALSA_CONF_FILES;
do
#extract name of board
board=`echo $f | sed -e "s|/etc/asound-\(.*\).conf|\1|"`
debug_print "board=$board"
#search on device tree compatible entry if the board are present
if `grep -q $board /proc/device-tree/compatible` ;
then
# device tree compatible entry match with board name
debug_print "use $f for asound.conf"
cp $f /etc/asound.conf
break;
fi
done
exit 0

View File

@ -0,0 +1,66 @@
#!/bin/sh
# Script which detect automaticaly the alsa-states file to put
# in place in fuonction of board on which the script are executed.
#
# This script are use with systemd-generators
# see man for more information or
# https://www.freedesktop.org/software/systemd/man/systemd.generator.html
#
# How to debug:
# mkdir /tmp/normal-dir /tmp/early-dir /tmp/late-dir
# SYSTEMD_LOG_LEVEL=debug /lib/systemd/system-generators/system-generator-alsa-states \
# /tmp/normal-dir /tmp/early-dir /tmp/late-dir
# find /tmp/normal-dir /tmp/early-dir /tmp/late-dir
#
#
function debug_print() {
if `echo $SYSTEMD_LOG_LEVEL |grep -q debug` ;
then
echo "[DEBUG] $@"
fi
}
#
# Main
#
if [ ! -d /proc/device-tree/ ];
then
debug_print "Proc Device tree are not available, Could not detect on which board we are"
exit 1
fi
if [ -e /var/lib/alsa/asound.state ];
then
LINE=`cat /var/lib/alsa/asound.state | wc -l`
if [ $LINE -lt 3 ];
then
# dummy alsa-state file contains only one comment
debug_print "remove previous dummy alsa-state file"
rm /var/lib/alsa/asound.state
else
debug_print "alsa-state file already configured"
exit 0
fi
fi
# get the name file available for alsa-states
ALSA_STATE_FILES=`ls -1 /var/lib/alsa/asound-*`
for f in $ALSA_STATE_FILES;
do
#extract name of board
board=`echo $f | sed -e "s|/var/lib/alsa/asound-\(.*\).state|\1|"`
#search on device tree compatible entry if the board are present
if `grep -q $board /proc/device-tree/compatible` ;
then
# device tree compatible entry match with board name
# configure alsa-state
if test -x /usr/sbin/alsactl
then
debug_print "active alsactl with $f"
#/usr/sbin/alsactl -f $f restore
cp $f /var/lib/alsa/asound.state
break;
fi
fi
done
exit 0