]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsactl: 90-alsa-restore.rules - add support for AMD ACP digital microphone
authorJaroslav Kysela <perex@perex.cz>
Mon, 11 Nov 2024 14:44:38 +0000 (15:44 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 11 Nov 2024 15:27:40 +0000 (16:27 +0100)
The UCM configuration for AMD ACP digital microphones combines HDA analog card
with ASoC AMD ACP digital microphone card. When the ACP microphone card
is detected later than HDA analog card, the UCM initialization for HDA
analog card should be executed again.

Additional changes:

Added --with-alsactl-udev-extra-test argument to handle the tests for
directories. The default value was kept.

Added --alsactl-udev-args argument to pass extra arguments to alsactl
in the udev rule.

Note: The autoconf does not handle correctly spaces so configure
call like 'configure --alsactl-udev-args="-E ENV=abcd"' is not allowed.
Substitue '__' string as ' ' for this reason.

Example:

   configure --with-alsactl-udev-args="-E__ENV=abcd" \
             --with-alsactl-udev-extra-test='TEST=="/abcd",__TEST=="/xyz",'

Closes: https://github.com/alsa-project/alsa-utils/issues/278
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
alsactl/90-alsa-restore.rules.in
alsactl/Makefile.am
configure.ac

index 1a411c99487086a38b2b9920615c9afef230732c..85f0b15f4856af4d6244b820c7f182514968b7ff 100644 (file)
@@ -1,8 +1,28 @@
-ACTION=="add", SUBSYSTEM=="sound", KERNEL=="controlC*", KERNELS!="card*", TEST=="@sbindir@", TEST=="@mydatadir@", GOTO="alsa_restore_go"
+# do not edit this file, it will be overwritten on update
+
+ACTION=="add", SUBSYSTEM=="sound", KERNEL=="controlC*", KERNELS!="card*",@extratest@ GOTO="alsa_restore_go"
 GOTO="alsa_restore_end"
 
+ENV{ALSA_CARD_NUMBER}="$attr{device/number}"
+
+# mark HDA analog card; HDMI/DP card does not have capture devices
+DRIVERS=="snd_hda_intel", TEST=="device/pcmC$env{ALSA_CARD_NUMBER}D0p", RUN+="/bin/sh -c 'echo ALSA_CARD_HDA_ANALOG=$env{ALSA_CARD_NUMBER} >> /run/udev/alsa-hda-analog-card'"
+
+# check for ACP hardware
+TEST=="device/device/acp3x-dmic-capture", GOTO="alsa_hda_analog"
+TEST=="device/device/acp6x-dmic-capture", GOTO="alsa_hda_analog"
+TEST=="device/device/acp63-dmic-capture", GOTO="alsa_hda_analog"
+TEST=="device/device/acp-pdm-dmic", GOTO="alsa_hda_analog"
+GOTO="alsa_restore_std"
+
+LABEL="alsa_hda_analog"
+# restore configuration for profile with combined cards (HDA + digital mic)
+TEST!="/run/udev/alsa-hda-analog-card", GOTO="alsa_restore_std"
+IMPORT{program}="/usr/bin/cat /run/udev/alsa-hda-analog-card"
+ENV{ALSA_CARD_HDA_ANALOG}!="", ENV{ALSA_CARD_NUMBER}="$env{ALSA_CARD_HDA_ANALOG}"
+
 LABEL="alsa_restore_go"
-TEST!="@daemonswitch@", RUN+="@sbindir@/alsactl restore $devnode"
-TEST=="@daemonswitch@", RUN+="@sbindir@/alsactl nrestore $devnode"
+TEST!="@daemonswitch@", RUN+="@sbindir@/alsactl@args@ restore $env{ALSA_CARD_NUMBER}"
+TEST=="@daemonswitch@", RUN+="@sbindir@/alsactl@args@ nrestore $env{ALSA_CARD_NUMBER}"
 
 LABEL="alsa_restore_end"
index fb32c4f3a632ffb5d9aa21b0a7772debf7ca364f..e7717173955cd91ca9e5e929d0a2163b7b341951 100644 (file)
@@ -43,10 +43,14 @@ install-data-hook:
 endif
 
 edit = \
+       extratest=$$(echo ' $(ALSACTL_UDEV_EXTRATEST)' | sed -e 's/__/ /g' -e 's/^ $$//'); \
+       args=$$(echo ' $(ALSACTL_UDEV_ARGS)' | sed -e 's/__/ /g' -e 's/^ $$//'); \
        $(SED) -r -e 's,@sbindir\@,$(sbindir),g' \
                  -e 's,@mydatadir\@,$(mydatadir),g' \
                  -e 's,@daemonswitch\@,$(ALSACTL_DAEMONSWITCH),g' \
                  -e 's,@asoundrcfile\@,$(ASOUND_STATE_DIR)/asound.state,g' \
+                 -e "s;@extratest\@;$${extratest};g" \
+                 -e "s;@args\@;$${args};g" \
                                                        < $< > $@ || rm $@
 
 alsa-state.service: alsa-state.service.in
index 4156985dc9e8ce216c9f1cc31af1d8740adb7307..1cf74d7fa142f80e407de181c02ac963d5ee8fac 100644 (file)
@@ -446,6 +446,21 @@ AC_ARG_WITH([alsactl-daemonswitch],
         [ALSACTL_DAEMONSWITCH="/etc/alsa/state-daemon.conf"])
 AC_SUBST(ALSACTL_DAEMONSWITCH)
 
+AC_ARG_WITH([alsactl-udev-extra-test],
+        AS_HELP_STRING([--with-alsactl-udev-extra-test=TEST], [Extra udev tests]),
+        [ALSACTL_UDEV_EXTRATEST="$withval"],
+        [ALSACTL_UDEV_EXTRATEST="default"])
+if test "$ALSACTL_UDEV_EXTRATEST" = "default"; then
+  ALSACTL_UDEV_EXTRATEST="TEST==\"${sbindir}\", TEST==\"${mydatadir}\","
+fi
+AC_SUBST(ALSACTL_UDEV_EXTRATEST)
+
+AC_ARG_WITH([alsactl-udev-args],
+        AS_HELP_STRING([--with-alsactl-udev-args=ARGS], [Extra alsactl arguments (udev rules)]),
+        [ALSACTL_UDEV_ARGS="$withval"],
+        [ALSACTL_UDEV_ARGS=""])
+AC_SUBST(ALSACTL_UDEV_ARGS)
+
 dnl pre-process plugin directory
 AC_ARG_WITH(plugindir,
     AS_HELP_STRING([--with-plugindir=dir],