]> git.alsa-project.org Git - alsa-ucm-conf.git/commitdiff
UCM2: Intel: sof-hda-dsp: Enable Dmic0 DRC and TDFB
authorSeppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Fri, 13 Dec 2024 17:30:47 +0000 (19:30 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 29 Jan 2025 09:21:59 +0000 (10:21 +0100)
This patch enables the SOF microphone capture pre-processing
features as BootSequence initial values if the controls for them
are available. If the user later switches these off, they will
remain off.

The DRC is dynamic range control that boosts the capture level,
and the TDFB (time-domain fixed beamformer) improves capture
signal-to-noise ratio for set beam angle direction. The used
0 degrees angle is defined as angle towards notebook computer
user.

The generic blobs in topology can be replaced with device
specific blobs based on DMI ID. See ucm2/blobs/sof/product_configs
and ucm2/blobs/sof/user_configs.

Closes: https://github.com/alsa-project/alsa-ucm-conf/pull/481
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
ucm2/Intel/sof-hda-dsp/dsp.conf
ucm2/Intel/sof-hda-dsp/sof-hda-dsp.conf

index a55eec8726e0872063f134dcee3b25e17407c49f..9480e66f220509d2bfebfa5bae217a87cbf116b9 100644 (file)
@@ -26,6 +26,12 @@ Define {
        PostMixerAnalogPlaybackFirBytes "N/A"
        PostMixerAnalogPlaybackDrcBytes "N/A"
        PostMixerAnalogPlaybackDrcSwitch "N/A"
+       Dmic0CaptureIirBytes "N/A"
+       Dmic0CaptureDrcBytes "N/A"
+       Dmic0CaptureDrcSwitch "N/A"
+       Dmic0CaptureBeamformerBytes "N/A"
+       Dmic0CaptureBeamformerBeamSwitch "N/A"
+       Dmic0CaptureBeamformerBeamAngleSet "N/A"
 }
 
 If.SOFIPCVer {
@@ -47,6 +53,21 @@ If.SOFIPCVer {
        }
 }
 
+If.SOFDmic0Proc {
+       Condition {
+               Type ControlExists
+               Control "name='DMIC0 Capture IIR Eq'"
+       }
+       True.Define {
+             Dmic0CaptureIirBytes "DMIC0 Capture IIR Eq"
+             Dmic0CaptureDrcBytes "Dmic0 Capture DRC bytes"
+             Dmic0CaptureDrcSwitch "Dmic0 Capture DRC switch"
+             Dmic0CaptureBeamformerBytes "Dmic0 Capture TDFB bytes"
+             Dmic0CaptureBeamformerBeamSwitch "Dmic0 Capture TDFB beam switch"
+             Dmic0CaptureBeamformerBeamAngleSet "Dmic0 Capture TDFB angle set enum"
+       }
+}
+
 If.SOFPath {
        Condition { Type AlwaysTrue }
        True.Define {
@@ -57,6 +78,12 @@ If.SOFPath {
                PostMixerAnalogPlaybackHeadphoneIirBlob "${var:BlobPath}/eq_iir/pass.blob"
                PostMixerAnalogPlaybackHeadphoneFirBlob "${var:BlobPath}/eq_fir/pass.blob"
                PostMixerAnalogPlaybackHeadphoneDrcBlob "${var:BlobPath}/drc/passthrough.blob"
+               # Leave Dmic0 default blobs empty to not override blobs in topology by default.
+               # The DMI ID based customization in blobs/sof/user_configs or
+               # blobs/sof/product_configs may set these as FixedBootConfig.
+               Dmic0CaptureDrcBlob ""
+               Dmic0CaptureBeamformerBlob ""
+               Dmic0CaptureIirBlob ""
                ConfPathFromDMI "${var:SOFVendor}/${var:SOFProduct}.conf"
                SOFProductConfig "/blobs/sof/product_configs/${var:ConfPathFromDMI}"
                SOFConfFullPath "${ConfTopDir}${var:SOFProductConfig}"
@@ -85,3 +112,94 @@ If.HasUserConfig {
                }
        }
 }
+
+DefineMacro.SofDrcBootSetup {
+       Define.ep_SwitchVar "${var:__endpoint}${var:__direction}DrcSwitch"
+       Define.ep_BytesVar "${var:__endpoint}${var:__direction}DrcBytes"
+       Define.ep_BlobVar "${var:__endpoint}${var:__direction}DrcBlob"
+       Define.EndpointDrcSwitch "${var:$ep_SwitchVar}"
+       Define.EndpointDrcBytes "${var:$ep_BytesVar}"
+       Define.EndpointDrcBlob "${var:$ep_BlobVar}"
+       If.EndpointMicDrc {
+               Condition {
+                       Type ControlExists
+                       Control "name='${var:EndpointDrcSwitch}'"
+               }
+               True {
+                       If.EndpointDrcBlobDefined {
+                               Condition {
+                                       Type String
+                                       Empty "${var:EndpointDrcBlob}"
+                               }
+                               False.FixedBootSequence [
+                                       #shell "/bin/echo 'Setting ${var:EndpointDrcBytes} to ${var:EndpointDrcBlob}' >> /tmp/alsa-ucm.txt"
+                                       cset-tlv "name='${var:EndpointDrcBytes}' ${var:EndpointDrcBlob}"
+                               ]
+                       }
+                       BootSequence [
+                               #shell "/bin/echo 'Switching ${var:EndpointDrcSwitch} on' >> /tmp/alsa-ucm.txt"
+                               cset "name='${var:EndpointDrcSwitch}' on"
+                       ]
+               }
+       }
+}
+
+DefineMacro.SofBeamformerBootSetup {
+       Define.ep_BeamSwitchVar "${var:__endpoint}${var:__direction}BeamformerBeamSwitch"
+       Define.ep_BeamAngleSetVar "${var:__endpoint}${var:__direction}BeamformerBeamAngleSet"
+       Define.ep_BytesVar "${var:__endpoint}${var:__direction}BeamformerBytes"
+       Define.ep_BlobVar "${var:__endpoint}${var:__direction}BeamformerBlob"
+       Define.EndpointBeamformerBeamSwitch "${var:$ep_BeamSwitchVar}"
+       Define.EndpointBeamformerBeamAngleSet "${var:$ep_BeamAngleSetVar}"
+       Define.EndpointBeamformerBytes "${var:$ep_BytesVar}"
+       Define.EndpointBeamformerBlob "${var:$ep_BlobVar}"
+       If.EndpointMicBeamformer {
+               Condition {
+                       Type ControlExists
+                       Control "name='${var:EndpointBeamformerBeamSwitch}'"
+               }
+               True {
+                       If.EndpointBeamformerBlobDefined {
+                               Condition {
+                                       Type String
+                                       Empty "${var:EndpointBeamformerBlob}"
+                               }
+                               False.FixedBootSequence [
+                                       #shell "/bin/echo 'Setting ${var:EndpointBeamformerBytes} to ${var:EndpointBeamformerBlob}' >> /tmp/alsa-ucm.txt"
+                                       cset-tlv "name='${var:EndpointBeamformerBytes}' ${var:EndpointBeamformerBlob}"
+                               ]
+                       }
+                       BootSequence [
+                               #shell "/bin/echo 'Switching ${var:EndpointBeamformerBeamSwitch} on' >> /tmp/alsa-ucm.txt"
+                               #shell "/bin/echo 'Setting ${var:EndpointBeamformerBeamAngleSet} 0' >> /tmp/alsa-ucm.txt"
+                               cset "name='${var:EndpointBeamformerBeamSwitch}' on"
+                               cset "name='${var:EndpointBeamformerBeamAngleSet}' 0"
+                       ]
+               }
+       }
+}
+
+DefineMacro.SofEqBootSetup {
+       Define.ep_BytesVar "${var:__endpoint}${var:__direction}${var:__eqtype}Bytes"
+       Define.ep_BlobVar "${var:__endpoint}${var:__direction}${var:__eqtype}Blob"
+       Define.EndpointEqBytes "${var:$ep_BytesVar}"
+       Define.EndpointEqBlob "${var:$ep_BlobVar}"
+       If.EndpointEq {
+               Condition {
+                       Type ControlExists
+                       Control "name='${var:EndpointEqBytes}'"
+               }
+               True {
+                       If.EndpointEqBlobDefined {
+                               Condition {
+                                       Type String
+                                       Empty "${var:EndpointEqBlob}"
+                               }
+                               False.FixedBootSequence [
+                                       #shell "/bin/echo 'Setting ${var:EndpointEqBytes} to ${var:EndpointEqBlob}' >> /tmp/alsa-ucm.txt"
+                                       cset-tlv "name='${var:EndpointEqBytes}' ${var:EndpointEqBlob}"
+                               ]
+                       }
+               }
+       }
+}
index 7469797d3ab568410cfc359c9f423f320bbb56ab..c14ecb85a56d21e46f61116b71699e925ba9a28a 100644 (file)
@@ -109,10 +109,15 @@ If.dmic {
                        Type ControlExists
                        Control "name='Dmic0 Capture Volume'"
                }
-               True.BootSequence [
-                       cset "name='Dmic0 Capture Volume' 70%"
-                       cset "name='Dmic0 Capture Switch' on"
-               ]
+               True {
+                       BootSequence [
+                               cset "name='Dmic0 Capture Volume' 70%"
+                               cset "name='Dmic0 Capture Switch' on"
+                       ]
+                       Macro.Dmic0.SofEqBootSetup "endpoint='Dmic0' direction='Capture' eqtype='Iir'"
+                       Macro.Dmic0.SofDrcBootSetup "endpoint='Dmic0' direction='Capture'"
+                       Macro.Dmic0.SofBeamformerBootSetup "endpoint=Dmic0 direction='Capture'"
+               }
        }
 }