From c476091a87a4cd43ad500f0f31baa4a8d35bd153 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 30 May 2024 18:28:10 +0300 Subject: [PATCH] UCM2: Intel: sof-hda-dsp: Control SOF processing from UCM This patch adds to Intel/sof-hda-dsp/HiFi.conf inclusion of HiFi-sof.conf that by redefine of headphone and speaker handling adds to UCM control of DRC and EQ SOF processing components. The modified setting are applied in case of SOF processing components' controls are detected. There is no change to operation if no controls are present e.g. with legacy SOF topology. If DRC control is found, it is assumed that also FIR and IIR also exist. If there is no DRC but FIR is found, then it is assumed that IIR also exists. This matches SOF FW builds for IPC3 (FIR, IIR) and IPC4 (DRC, FIR, IIR). The controls names are different in IPC3 and IPC4 topologies. Also the configuration blobs differ. The speaker mode is by default set up with 100 Hz high-pass IIR. The DRC is set to a default speaker setting that boosts playback loudness. The FIR is bypassed. In the headphone mode all the processing is set to bypass and DRC switch is set off. The processing can be customized for products with UCM scripts placed into blobs/sof/product_configs. The file path should be /.conf from DMI ID. An user configuration can be similarly placed into blobs/sof/user_configs directory to e.g. avoid it being overwritten by distribution. Closes: https://github.com/alsa-project/alsa-ucm-conf/pull/419 Signed-off-by: Seppo Ingalsuo Signed-off-by: Jaroslav Kysela --- ucm2/Intel/sof-hda-dsp/HiFi-sof.conf | 123 +++++++++++++++++++++++++++ ucm2/Intel/sof-hda-dsp/HiFi.conf | 2 + 2 files changed, 125 insertions(+) create mode 100644 ucm2/Intel/sof-hda-dsp/HiFi-sof.conf diff --git a/ucm2/Intel/sof-hda-dsp/HiFi-sof.conf b/ucm2/Intel/sof-hda-dsp/HiFi-sof.conf new file mode 100644 index 0000000..90af859 --- /dev/null +++ b/ucm2/Intel/sof-hda-dsp/HiFi-sof.conf @@ -0,0 +1,123 @@ +# Control audio processing in SOF + +# File paths for controlling SOF processing + +If.SOFIPCVer { + Condition { + Type ControlExists + Control "name='Post Mixer Analog Playback IIR Eq bytes'" + } + True.Define { + SOFIPCVer "ipc4" + PostMixerAnalogPlaybackIIRBytes "Post Mixer Analog Playback IIR Eq bytes" + PostMixerAnalogPlaybackFIRBytes "Post Mixer Analog Playback FIR Eq bytes" + PostMixerAnalogPlaybackDRCBytes "Post Mixer Analog Playback DRC bytes" + PostMixerAnalogPlaybackDRCSwitch "Post Mixer Analog Playback DRC switch" + } + False.Define { + SOFIPCVer "ipc3" + PostMixerAnalogPlaybackIIRBytes "EQIIR1.0 eqiir_coef_1" + PostMixerAnalogPlaybackFIRBytes "EQFIR1.0 eqfir_coef_1" + PostMixerAnalogPlaybackDRCBytes "not available" + PostMixerAnalogPlaybackDRCSwitch "not available" + } +} + +If.SOFPath { + Condition { Type AlwaysTrue } + True.Define { + BlobPath "${ConfTopDir}/blobs/sof/${var:SOFIPCVer}" + SpeakerIirBlob "${var:BlobPath}/eq_iir/highpass_100hz_0db_48khz.blob" + SpeakerFirBlob "${var:BlobPath}/eq_fir/pass.blob" + SpeakerDrcBlob "${var:BlobPath}/drc/speaker_default.blob" + HeadphoneIirBlob "${var:BlobPath}/eq_iir/pass.blob" + HeadphoneFirBlob "${var:BlobPath}/eq_fir/pass.blob" + HeadphoneDrcBlob "${var:BlobPath}/drc/passthrough.blob" + } +} + +Define.ConfPathFromDMI "${sys:devices/virtual/dmi/id/sys_vendor}/${sys:devices/virtual/dmi/id/product_name}.conf" +Define.SOFProductConfig "/blobs/sof/product_configs/${var:ConfPathFromDMI}" +Define.SOFConfFullPath "${ConfTopDir}${var:SOFProductConfig}" +Define.SOFUserConfig "/blobs/sof/user_configs/${var:ConfPathFromDMI}" +Define.SOFUserConfFullPath "${ConfTopDir}${var:SOFUserConfig}" + +If.HasUserConfig { + Condition { + Type Path + Mode read + Path "${var:SOFUserConfFullPath}" + } + True { + Include.product-config.File "${var:SOFUserConfig}" + } + False.If.HasProductConfig { + Condition { + Type Path + Mode read + Path "${var:SOFConfFullPath}" + } + True { + Include.product-config.File "${var:SOFProductConfig}" + } + } +} + +# Redefine headphone control FOR SOF. This is same as Headphone in HDA/HiFi-analog.conf +# but adds DRC and EQ controls. + +DefineMacro.SofControl { + Define.EndpointDrcVar "${var:__endpoint}DrcBlob" + Define.EndpointIirVar "${var:__endpoint}IirBlob" + Define.EndpointFirVar "${var:__endpoint}FirBlob" + Define.EndpointDrcBlob "${var:$EndpointDrcVar}" + Define.EndpointIirBlob "${var:$EndpointIirVar}" + Define.EndpointFirBlob "${var:$EndpointFirVar}" + + If.endpoint_with_drc { + Condition { + Type ControlExists + Control "name='${var:PostMixerAnalogPlaybackDRCSwitch}'" + } + True { + EnableSequence [ + # For debug uncomment below the echo command to see what blobs are applied + #shell "/bin/echo '${var:__endpoint} ${var:EndpointIirBlob} ${var:EndpointFirBlob} ${var:EndpointDrcBlob}' >> /tmp/alsa-ucm.txt" + cset "name='${var:PostMixerAnalogPlaybackDRCSwitch}' ${var:__drcswitch}" + cset-tlv "name='${var:PostMixerAnalogPlaybackDRCBytes}' ${var:EndpointDrcBlob}" + cset-tlv "name='${var:PostMixerAnalogPlaybackIIRBytes}' ${var:EndpointIirBlob}" + cset-tlv "name='${var:PostMixerAnalogPlaybackFIRBytes}' ${var:EndpointFirBlob}" + ] + } + False.If.endpoint_with_eq { + Condition { + Type ControlExists + Control "name='${var:PostMixerAnalogPlaybackFIRBytes}'" + } + True { + EnableSequence [ + # For debug uncomment below the echo command to see what blobs are applied + #shell "/bin/echo '${var:__endpoint} ${var:EndpointIirBlob} ${var:EndpointFirBlob}' >> /tmp/alsa-ucm.txt" + cset-tlv "name='${var:PostMixerAnalogPlaybackIIRBytes}' ${var:EndpointIirBlob}" + cset-tlv "name='${var:PostMixerAnalogPlaybackFIRBytes}' ${var:EndpointFirBlob}" + ] + } + } + } +} + +# Merge this to Headpones subtree in HDA/HiFi-analog.conf +SectionDevice."Headphones" { + Macro.headphone.SofControl "endpoint=Headphone drcswitch=off" +} + +# Merge this to Speaker subtree in HDA/HiFi-analog.conf +If.spk { + Condition { + Type ControlExists + Control "name='Speaker Playback Switch'" + } + True.SectionDevice."Speaker" { + Macro.speaker.SofControl "endpoint=Speaker drcswitch=on" + } +} diff --git a/ucm2/Intel/sof-hda-dsp/HiFi.conf b/ucm2/Intel/sof-hda-dsp/HiFi.conf index 2063fc0..9689b56 100644 --- a/ucm2/Intel/sof-hda-dsp/HiFi.conf +++ b/ucm2/Intel/sof-hda-dsp/HiFi.conf @@ -10,6 +10,8 @@ SectionVerb { Include.hda-analog.File "/HDA/HiFi-analog.conf" +Include.sof-analog.File "HiFi-sof.conf" + If.dmic { Condition { Type String -- 2.47.1