Skip to content

Commit

Permalink
UCM2: Intel: sof-hda-dsp: Control SOF processing from UCM
Browse files Browse the repository at this point in the history
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
<sys_vendor>/<product_name>.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: #419
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
  • Loading branch information
singalsu authored and perexg committed May 31, 2024
1 parent cebe689 commit c476091
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
123 changes: 123 additions & 0 deletions ucm2/Intel/sof-hda-dsp/HiFi-sof.conf
Original file line number Diff line number Diff line change
@@ -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"
}
}
2 changes: 2 additions & 0 deletions ucm2/Intel/sof-hda-dsp/HiFi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c476091

Please sign in to comment.