From d920d096436a7fe7f7e36d41273a3d7fced85399 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 13 Dec 2024 19:30:47 +0200 Subject: [PATCH] UCM2: Intel: sof-hda-dsp: Enable Dmic0 DRC and TDFB 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 Signed-off-by: Jaroslav Kysela --- ucm2/Intel/sof-hda-dsp/dsp.conf | 118 ++++++++++++++++++++++++ ucm2/Intel/sof-hda-dsp/sof-hda-dsp.conf | 13 ++- 2 files changed, 127 insertions(+), 4 deletions(-) diff --git a/ucm2/Intel/sof-hda-dsp/dsp.conf b/ucm2/Intel/sof-hda-dsp/dsp.conf index a55eec8..9480e66 100644 --- a/ucm2/Intel/sof-hda-dsp/dsp.conf +++ b/ucm2/Intel/sof-hda-dsp/dsp.conf @@ -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}" + ] + } + } + } +} diff --git a/ucm2/Intel/sof-hda-dsp/sof-hda-dsp.conf b/ucm2/Intel/sof-hda-dsp/sof-hda-dsp.conf index 7469797..c14ecb8 100644 --- a/ucm2/Intel/sof-hda-dsp/sof-hda-dsp.conf +++ b/ucm2/Intel/sof-hda-dsp/sof-hda-dsp.conf @@ -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'" + } } } -- 2.47.1