Skip to contentSkip to conversation

Add alsa-state from OE Classic v3

PATCH Applied Joshua Lock 4 participants 11 messages Jan 13, 2012 – Jan 27, 2012

lore
Share & tools
lore
#0 lore raw

cover Add alsa-state from OE Classic v3

The small series which follows introduces the alsa-state recipe from oe-classic. The reason for doing so is to remove the requirement for recipes like the beagleboard-audio recipe in meta-yocto, which ensures the beagleboards sound device has the volume turned up.

Long term I'd like to implement something more generic for handling device quirks, but alsa-state is a simple fix for an immediate need that should standardise how alsa configuration is handled in layers.

Since v1 I added an extra commit which:
a) defaults to /var/lib/alsa/ for state files, as this is the directory alsactl writes to by default.
b) sed's the path to the state files into the init script, rather than hard coding them.

Since v2 I've modified the task-base commit to add VIRTUAL-RUNTIME_alsa-state rather than hard code the alsa-state recipe per suggestion from Martin Jansa and added an extra commit to move the defintion of VIRTUAL-RUNTIME_apm from task-base to default-providers.inc

Cheers,

Joshua

The following changes since commit bd047935305c872b565f30b46c94b7077e5fb3a2:

patch.bbclass: Ensure the DATE and SRCDATE variable exclusions apply to the correct function (2012-01-13 16:56:20 +0000)

are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib josh/devices
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=josh/devices

Joshua Lock (4):
task-base: move default definition of VIRTUAL-RUNTIME_apm
alsa-state: add alsa-state from oe classic
alsa-state: move state files to localstatedir
task-base: add VIRTUAL-RUNTIME_alsa-state to task-base-alsa

 meta/conf/distro/include/default-providers.inc     |    2 +
 meta/recipes-bsp/alsa-state/alsa-state.bb          |   59 ++++++++++++++++++++
 meta/recipes-bsp/alsa-state/alsa-state/alsa-state  |   29 ++++++++++
 meta/recipes-bsp/alsa-state/alsa-state/asound.conf |   12 ++++
 .../recipes-bsp/alsa-state/alsa-state/asound.state |    1 +
 meta/recipes-core/tasks/task-base.bb               |    8 +--
 6 files changed, 106 insertions(+), 5 deletions(-)
 create mode 100644 meta/recipes-bsp/alsa-state/alsa-state.bb
 create mode 100755 meta/recipes-bsp/alsa-state/alsa-state/alsa-state
 create mode 100644 meta/recipes-bsp/alsa-state/alsa-state/asound.conf
 create mode 100644 meta/recipes-bsp/alsa-state/alsa-state/asound.state
Signature · 1 line
1.7.7.5
#1 lore raw

PATCH 1/4 task-base: move default definition of VIRTUAL-RUNTIME_apm

This belongs in default-providers.conf

---
 meta/conf/distro/include/default-providers.inc |    1 +
 meta/recipes-core/tasks/task-base.bb           |    3 ---
 2 files changed, 1 insertions(+), 3 deletions(-)
meta/conf/distro/include/default-providers.inc +1 -0
index afea5e7..2445049 100644
@@ -15,6 +15,7 @@ PREFERRED_PROVIDER_xf86-video-intel ?= "xf86-video-intel"
 # Default virtual runtime providers
 #
 VIRTUAL-RUNTIME_update-alternatives ?= "update-alternatives-cworth"
+VIRTUAL-RUNTIME_apm ?= "apm"
 
 #
 # Default recipe providers
meta/recipes-core/tasks/task-base.bb +0 -3
index e0960b5..12e171a 100644
@@ -162,9 +162,6 @@ RDEPENDS_task-base-acpi = "\
     acpid \
     libacpi "
 
-# Distro can override apm provider
-VIRTUAL-RUNTIME_apm ?= "apm"
-
 RDEPENDS_task-base-apm = "\
     ${VIRTUAL-RUNTIME_apm} \
     apmd"
Signature · 1 line
1.7.7.5
#2 lore raw

PATCH 2/4 alsa-state: add alsa-state from oe classic

In reply to Joshua Lock

alsa-state adds an init script and configuration files to enable a consistent and centralised mechanism for setting and restoring alsa configuration.

---
 meta/recipes-bsp/alsa-state/alsa-state.bb          |   57 ++++++++++++++++++++
 meta/recipes-bsp/alsa-state/alsa-state/alsa-state  |   29 ++++++++++
 meta/recipes-bsp/alsa-state/alsa-state/asound.conf |   12 ++++
 .../recipes-bsp/alsa-state/alsa-state/asound.state |    1 +
 4 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 meta/recipes-bsp/alsa-state/alsa-state.bb
 create mode 100755 meta/recipes-bsp/alsa-state/alsa-state/alsa-state
 create mode 100644 meta/recipes-bsp/alsa-state/alsa-state/asound.conf
 create mode 100644 meta/recipes-bsp/alsa-state/alsa-state/asound.state
meta/recipes-bsp/alsa-state/alsa-state.bb new file +57 -0
new file mode 100644
index 0000000..ecfa975
@@ -0,0 +1,57 @@
+# Copyright Matthias Hentges <[email protected]> (c) 2007
+# License: MIT (see http://www.opensource.org/licenses/mit-license.php
+#               for a copy of the license)
+#
+# Filename: alsa-state.bb
+
+SUMMARY = "Alsa scenario files to enable alsa state restoration."
+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 = "0.2.0"
+PR = "r0"
+
+SRC_URI = "\
+  file://asound.conf \
+  file://asound.state \
+  file://alsa-state \
+"
+
+RDEPENDS = "alsa-utils-alsactl"
+
+inherit update-rc.d
+
+INITSCRIPT_NAME = "alsa-state"
+INITSCRIPT_PARAMS = "start 39 S . stop 31 0 6 ."
+
+do_install() {
+    install -d ${D}${sysconfdir}/init.d
+    install -m 0755 ${WORKDIR}/alsa-state ${D}${sysconfdir}/init.d
+
+    install -m 0644 ${WORKDIR}/asound.conf ${D}${sysconfdir}
+    install -m 0644 ${WORKDIR}/*.state ${D}${sysconfdir}
+}
+
+PACKAGES += "alsa-states"
+
+RRECOMMENDS_alsa-state = "alsa-states"
+
+FILES_${PN} = "${sysconfdir}/init.d ${sysconfdir}/asound.conf"
+CONFFILES_${PN} = "${sysconfdir}/asound.conf"
+
+FILES_alsa-states = "${sysconfdir}/*.state"
+
+pkg_postinst_${PN}() {
+	if test -z "$D"
+	then
+		if test -x /usr/sbin/alsactl
+		then
+			/usr/sbin/alsactl -f ${sysconfdir}/asound.state restore
+		fi
+		# INITSCRIPT_PARAMS changed, so remove the old and
+		# install the new setting.
+		update-rc.d -f ${INITSCRIPT_NAME} remove
+		update-rc.d ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
+	fi
+}
meta/recipes-bsp/alsa-state/alsa-state/alsa-state new file +29 -0
new file mode 100755
index 0000000..84cdf03
@@ -0,0 +1,29 @@
+#! /bin/sh
+#
+# Copyright Matthias Hentges <[email protected]> (c) 2007
+# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the license)
+#
+# Filename: alsa-state
+# Date: 20070308 (YMD)
+
+
+asound_restore(){
+	echo "ALSA: Restoring mixer settings..."
+	if test -x /usr/sbin/alsactl -a -e /etc/asound.state
+	then
+		/usr/sbin/alsactl -f /etc/asound.state restore &
+	fi
+}
+
+asound_store(){
+	echo "ALSA: Storing mixer settings..."
+	if test -x /usr/sbin/alsactl
+	then
+		/usr/sbin/alsactl -f /etc/asound.state store
+	fi
+}
+
+case "$1" in
+start)		asound_restore ;;
+stop)		asound_store ;;
+esac
meta/recipes-bsp/alsa-state/alsa-state/asound.conf new file +12 -0
new file mode 100644
index 0000000..6be0242
@@ -0,0 +1,12 @@
+# default dmix configuration
+
+pcm.!default {
+    type plug
+    slave.pcm "dmix"
+}
+
+ctl.mixer0 {
+    type hw
+    card 0
+}
+
meta/recipes-bsp/alsa-state/alsa-state/asound.state new file +1 -0
new file mode 100644
index 0000000..ddd1cce
@@ -0,0 +1 @@
+# Dummy file, do not delete
Signature · 1 line
1.7.7.5
#4 lore raw

PATCH 4/4 task-base: add VIRTUAL-RUNTIME_alsa-state to task-base-alsa

In reply to Joshua Lock

Define this to be the alsa-state package by default. This enables automatic configuration setting and restoration on systems with alsa.

---
 meta/conf/distro/include/default-providers.inc |    1 +
 meta/recipes-core/tasks/task-base.bb           |    5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)
meta/conf/distro/include/default-providers.inc +1 -0
index 2445049..6615d55 100644
@@ -16,6 +16,7 @@ PREFERRED_PROVIDER_xf86-video-intel ?= "xf86-video-intel"
 #
 VIRTUAL-RUNTIME_update-alternatives ?= "update-alternatives-cworth"
 VIRTUAL-RUNTIME_apm ?= "apm"
+VIRTUAL-RUNTIME-alsa-state ?= "alsa-state"
 
 #
 # Default recipe providers
meta/recipes-core/tasks/task-base.bb +3 -2
index 12e171a..a7d7c40 100644
@@ -2,7 +2,7 @@ DESCRIPTION = "Merge machine and distro options to create a basic machine task/p
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \
                     file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
-PR = "r72"
+PR = "r73"
 
 inherit task
 
@@ -180,7 +180,8 @@ RRECOMMENDS_task-base-vfat = "\
 
 RDEPENDS_task-base-alsa = "\
     alsa-utils-alsactl \
-    alsa-utils-alsamixer"
+    alsa-utils-alsamixer \
+    ${VIRTUAL-RUNTIME-alsa-state}"
 
 RRECOMMENDS_task-base-alsa = "\
     kernel-module-snd-mixer-oss \
Signature · 1 line
1.7.7.5
#3 lore raw

PATCH 3/4 alsa-state: move state files to localstatedir

In reply to Joshua Lock

alsactl creates the state files in /var/lib/alsa by default so switch alsa-state to use files in that location.

Further, update the alsa-state init script to have the location of the state files sed'ed into the script at do_install time (so as to remove hard coding of directory paths).

---
 meta/recipes-bsp/alsa-state/alsa-state.bb         |    8 +++++---
 meta/recipes-bsp/alsa-state/alsa-state/alsa-state |    6 +++---
 2 files changed, 8 insertions(+), 6 deletions(-)
meta/recipes-bsp/alsa-state/alsa-state.bb +5 -3
index ecfa975..bc17b25 100644
@@ -26,11 +26,13 @@ INITSCRIPT_NAME = "alsa-state"
 INITSCRIPT_PARAMS = "start 39 S . stop 31 0 6 ."
 
 do_install() {
+    sed -i -e "s:#STATEDIR#:${localstatedir}/lib/alsa:g" ${WORKDIR}/alsa-state
     install -d ${D}${sysconfdir}/init.d
     install -m 0755 ${WORKDIR}/alsa-state ${D}${sysconfdir}/init.d
 
+    install -d ${D}/${localstatedir}/lib/alsa
     install -m 0644 ${WORKDIR}/asound.conf ${D}${sysconfdir}
-    install -m 0644 ${WORKDIR}/*.state ${D}${sysconfdir}
+    install -m 0644 ${WORKDIR}/*.state ${D}${localstatedir}/lib/alsa
 }
 
 PACKAGES += "alsa-states"
@@ -40,14 +42,14 @@ RRECOMMENDS_alsa-state = "alsa-states"
 FILES_${PN} = "${sysconfdir}/init.d ${sysconfdir}/asound.conf"
 CONFFILES_${PN} = "${sysconfdir}/asound.conf"
 
-FILES_alsa-states = "${sysconfdir}/*.state"
+FILES_alsa-states = "${localstatedir}/lib/alsa/*.state"
 
 pkg_postinst_${PN}() {
 	if test -z "$D"
 	then
 		if test -x /usr/sbin/alsactl
 		then
-			/usr/sbin/alsactl -f ${sysconfdir}/asound.state restore
+			/usr/sbin/alsactl -f ${localstatedir}/lib/alsa/asound.state restore
 		fi
 		# INITSCRIPT_PARAMS changed, so remove the old and
 		# install the new setting.
meta/recipes-bsp/alsa-state/alsa-state/alsa-state +3 -3
index 84cdf03..9850791 100755
@@ -9,9 +9,9 @@
 
 asound_restore(){
 	echo "ALSA: Restoring mixer settings..."
-	if test -x /usr/sbin/alsactl -a -e /etc/asound.state
+	if test -x /usr/sbin/alsactl -a -e #STATEDIR#/asound.state
 	then
-		/usr/sbin/alsactl -f /etc/asound.state restore &
+		/usr/sbin/alsactl -f #STATEDIR#/asound.state restore &
 	fi
 }
 
@@ -19,7 +19,7 @@ asound_store(){
 	echo "ALSA: Storing mixer settings..."
 	if test -x /usr/sbin/alsactl
 	then
-		/usr/sbin/alsactl -f /etc/asound.state store
+		/usr/sbin/alsactl -f #STATEDIR#/asound.state store
 	fi
 }
 
Signature · 1 line
1.7.7.5
Applied
#5 lore raw
In reply to Joshua Lock
Quoted 45 lines · Joshua Lock

The small series which follows introduces the alsa-state recipe from oe-classic. The reason for doing so is to remove the requirement for recipes like the beagleboard-audio recipe in meta-yocto, which ensures the beagleboards sound device has the volume turned up.

Long term I'd like to implement something more generic for handling device quirks, but alsa-state is a simple fix for an immediate need that should standardise how alsa configuration is handled in layers.

Since v1 I added an extra commit which:
a) defaults to /var/lib/alsa/ for state files, as this is the directory alsactl writes to by default.
b) sed's the path to the state files into the init script, rather than hard coding them.

Since v2 I've modified the task-base commit to add VIRTUAL-RUNTIME_alsa-state rather than hard code the alsa-state recipe per suggestion from Martin Jansa and added an extra commit to move the defintion of VIRTUAL-RUNTIME_apm from task-base to default-providers.inc

Cheers,

Joshua

The following changes since commit bd047935305c872b565f30b46c94b7077e5fb3a2:

patch.bbclass: Ensure the DATE and SRCDATE variable exclusions apply to the correct function (2012-01-13 16:56:20 +0000)

are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib josh/devices
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=josh/devices

Joshua Lock (4):
task-base: move default definition of VIRTUAL-RUNTIME_apm
alsa-state: add alsa-state from oe classic
alsa-state: move state files to localstatedir
task-base: add VIRTUAL-RUNTIME_alsa-state to task-base-alsa

  meta/conf/distro/include/default-providers.inc     |    2 +
  meta/recipes-bsp/alsa-state/alsa-state.bb          |   59 ++++++++++++++++++++
  meta/recipes-bsp/alsa-state/alsa-state/alsa-state  |   29 ++++++++++
  meta/recipes-bsp/alsa-state/alsa-state/asound.conf |   12 ++++
  .../recipes-bsp/alsa-state/alsa-state/asound.state |    1 +
  meta/recipes-core/tasks/task-base.bb               |    8 +--
  6 files changed, 106 insertions(+), 5 deletions(-)
Quoted 5 lines

create mode 100644 meta/recipes-bsp/alsa-state/alsa-state.bb create mode 100755 meta/recipes-bsp/alsa-state/alsa-state/alsa-state create mode 100644 meta/recipes-bsp/alsa-state/alsa-state/asound.conf create mode 100644 meta/recipes-bsp/alsa-state/alsa-state/asound.state

Merged into OE-Core

Thanks
Sau!

#6 lore raw
In reply to Joshua Lock

Op 13 jan. 2012, om 20:10 heeft Joshua Lock het volgende geschreven:

Quoted 8 lines

The small series which follows introduces the alsa-state recipe from oe-classic. The reason for doing so is to remove the requirement for recipes like the beagleboard-audio recipe in meta-yocto, which ensures the beagleboards sound device has the volume turned up.

Long term I'd like to implement something more generic for handling device quirks, but alsa-state is a simple fix for an immediate need that should standardise how alsa configuration is handled in layers.

FWIW, alsa-lib itself includes initscripts to do this. I dropped asound.state in /var/lib/alsa and it just worked since alsactl also installs systemd units to handle this. So alsa-state can just hold the config files and drop the initscripts by the looks of it.

regards,

Koen

#7 lore raw
Quoted 8 lines · Koen Kooi

Op 13 jan. 2012, om 20:10 heeft Joshua Lock het volgende geschreven:

Quoted 5 lines

The small series which follows introduces the alsa-state recipe from oe-classic. The reason for doing so is to remove the requirement for recipes like the beagleboard-audio recipe in meta-yocto, which ensures the beagleboards sound device has the volume turned up.

Quoted 5 lines
Quoted 3 lines

Long term I'd like to implement something more generic for handling device quirks, but alsa-state is a simple fix for an immediate need that should standardise how alsa configuration is handled in layers.

FWIW, alsa-lib itself includes initscripts to do this. I dropped asound.state in /var/lib/alsa and it just worked since alsactl also installs systemd units to handle this. So alsa-state can just hold the config files and drop the initscripts by the looks of it.

Thanks for raising this, I hadn't seen that alsa-utils provides some extras with alsactl.

Taking a quick look I see that they ship systemd units for state save and restore and a udev rule for restoring the state.

I can't see any initscript, so I think switching to what's provided by alsa-utils would mean losing state saving for non-systemd folk but systemd users can probably just set VIRTUAL-RUNTIME_alsa-state = "alsa-utils-alsactl".

I am an alsa newb so if I'm missing something please point me at it.

Cheers,
Joshua

Signature · 3 lines
Joshua Lock
        Yocto Project "Johannes factotum"
        Intel Open Source Technology Centre
#8 lore raw
Quoted 5 lines · Joshua Lock

I can't see any initscript, so I think switching to what's provided by alsa-utils would mean losing state saving for non-systemd folk but systemd users can probably just set VIRTUAL-RUNTIME_alsa-state = "alsa-utils-alsactl".

You still needs the state. So I think we'd need to have a specific -systemd version of it when the configs and the units.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
E-mail: [email protected]  http://www.ossystems.com.br
Mobile: +55 53 9981-7854              http://projetos.ossystems.com.br
#9 lore raw

Op 27 jan. 2012, om 00:09 heeft Otavio Salvador het volgende geschreven:

Quoted 4 lines · Joshua Lock

I can't see any initscript, so I think switching to what's provided by alsa-utils would mean losing state saving for non-systemd folk but systemd users can probably just set VIRTUAL-RUNTIME_alsa-state = "alsa-utils-alsactl".

You still needs the state. So I think we'd need to have a specific -systemd version of it when the configs and the units.

I was thinking of splitting the existing recipe into alsa-state-conf for the conf files and keep the init stuff in ${PN}. As a follow on patch we can have alsa-utils-alsactl RRECOMMEND alsa-state-conf.

thoughts?

regards,

Koen

#10 lore raw
Quoted 7 lines · Koen Kooi

Op 27 jan. 2012, om 00:09 heeft Otavio Salvador het volgende geschreven:

Quoted 4 lines · Joshua Lock

I can't see any initscript, so I think switching to what's provided by alsa-utils would mean losing state saving for non-systemd folk but systemd users can probably just set VIRTUAL-RUNTIME_alsa-state = "alsa-utils-alsactl".

You still needs the state. So I think we'd need to have a specific -systemd version of it when the configs and the units.

Quite right, we should separate the state files. I wasn't thinking straight there.

Quoted 4 lines

I was thinking of splitting the existing recipe into alsa-state-conf for the conf files and keep the init stuff in ${PN}. As a follow on patch we can have alsa-utils-alsactl RRECOMMEND alsa-state-conf.

thoughts?

Sounds good to me. I'd like to see what Martin thinks, as he rose the initial concern re: the VIRTUAL_RUNTIME. Hopefully SHR would also like the state files separate and more centrally maintained.

Cheers,
Joshua

Signature · 3 lines
Joshua Lock
        Yocto Project "Johannes factotum"
        Intel Open Source Technology Centre