Skip to content

audio: eq_iir: tune: add sof_ucm2_eq_generate#10980

Open
singalsu wants to merge 2 commits into
thesofproject:mainfrom
singalsu:add_sof_ucm2_eq_generate
Open

audio: eq_iir: tune: add sof_ucm2_eq_generate#10980
singalsu wants to merge 2 commits into
thesofproject:mainfrom
singalsu:add_sof_ucm2_eq_generate

Conversation

@singalsu

@singalsu singalsu commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

This patch adds an automatic UCMv2 configuration generator for SOF equalizers. An example speaker speaker demo case can be run:

>> sof_ucm2_eq_generate('example', 'example', 'speaker', 'sof_ucm2_eq_example.xlsx');
Averaged 2 response columns from sof_ucm2_eq_example.xlsx
Stage 1 (mid PN2): fc=2000.0 Hz  g=-12.00 dB  Q=0.50
Stage 2 bass gain upper bound = 12.00 dB (mid atten -12.00 dB, cap 26.0 dB)
Stage 2 (LS2): fc=195.4 Hz  g=12.00 dB
Stage 3 (fine PN2): fc=342.2 Hz  g=-6.00 dB  Q=0.50
FIR: length=63 taps, mid band [400, 7000] Hz

etc.

It produces for automatic DMI ID names based inclusion to UCM2 the configuration:

$ cat ucm2_blobs_sof/product_configs/example/example.conf 
# Add bespoke speaker equalizer for example example
#
# This file was generated with sof_ucm2_eq_generate.m
#
# IIR is defined as parametric equalizer and FIR carries the mid-band residual
# correction, see:
# https://github.com/thesofproject/sof/tree/main/src/audio/eq_iir/tune
#
# IIR biquad stages:
#     type    fc [Hz]    gain [dB]      Q
#     HP2       80.0      +0.00      0.00
#     PN2     2000.0     -12.00      0.50
#     LS2      195.4     +12.00      0.00
#     PN2      342.2      -6.00      0.50
#
# FIR parameters:
#     length      = 63 taps
#     kaiser beta = 10
#     minph       = 1
#     band        = [400, 7000] Hz

Define.PostMixerSpeakerPlaybackIirBlob "/usr/share/alsa/ucm2/blobs/sof/ipc4/eq_iir/speaker_example_example_iir.bin"
Define.PostMixerSpeakerPlaybackFirBlob "/usr/share/alsa/ucm2/blobs/sof/ipc4/eq_fir/speaker_example_example_fir.bin"

The graphical output from Octave can be used for visual check for sane design:

Screenshot From 2026-07-09 11-44-51

Add two small example endpoint frequency-response measurements so
the sof_ucm2_eq_generate script added in the following commit can
be exercised without external input:

  sof_ucm2_eq_example.txt   1024x3 (freq Hz, response L, response R)
  sof_ucm2_eq_example.xlsx  identical numeric grid in Excel form

Both files share the same [frequency, magnitude...] layout the
loader expects, so they also demonstrate the multi-column
averaging code path.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu singalsu marked this pull request as ready for review July 8, 2026 11:37
Copilot AI review requested due to automatic review settings July 8, 2026 11:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Octave-based generator that fits a combined IIR+FIR EQ from measurement data and emits both SOF IPC4 EQ blobs and a corresponding UCMv2 include file for automatic product config inclusion.

Changes:

  • Introduce sof_ucm2_eq_generate() to load measurements, fit a constrained multi-stage IIR, design a short mid-band FIR residual corrector, and export IPC4 blobs + UCM .conf.
  • Add a sample comma-separated measurement dataset (sof_ucm2_eq_example.txt) intended for demonstrating/validating the generator workflow.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/audio/eq_iir/tune/sof_ucm2_eq_generate.m New Octave function to generate IPC4 EQ blobs and a UCMv2 include from measurement data.
src/audio/eq_iir/tune/sof_ucm2_eq_example.txt Example CSV-like measurement input for the generator.

Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m Outdated
Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m
Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m Outdated
Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m Outdated
@singalsu singalsu requested review from kv2019i and lgirdwood July 8, 2026 14:02
@singalsu

singalsu commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

Some issue with the UCM bin blob -> draft

@singalsu singalsu marked this pull request as draft July 8, 2026 14:51
@singalsu singalsu force-pushed the add_sof_ucm2_eq_generate branch from 8e3cb46 to a14e7df Compare July 8, 2026 17:15
@singalsu singalsu marked this pull request as ready for review July 8, 2026 17:16
@singalsu singalsu requested a review from Copilot July 8, 2026 17:16
@singalsu

singalsu commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

Sounds good now, draft --> proposal.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m
Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m Outdated
Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m Outdated
Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m Outdated
Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m Outdated
Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m
Add a tuning script that turns a measured endpoint frequency
response into a pair of IIR + FIR blobs and a UCM2 include file
laid out the way alsa-ucm-conf expects. The IIR is a four-biquad
parametric (HP2 + low-Q mid PN2 + LS2 + one fine PN2 corrector)
fit stage-by-stage with fminsearch, and the residual mid-band
delta is picked up by a short minimum-phase FIR.

The script takes the DMI sys_vendor and product_name from
/sys/devices/virtual/dmi/id and an endpoint name, and produces:

  ucm2_blobs_sof/ipc4/eq_iir/<endpoint>_<vendor>_<product>_iir.{txt,bin}
  ucm2_blobs_sof/ipc4/eq_fir/<endpoint>_<vendor>_<product>_fir.{txt,bin}
  ucm2_blobs_sof/product_configs/<SYS_VENDOR>/<PRODUCT_NAME>.conf

The blob file names are lowercased and non-alphanumeric runs are
folded to underscores; the vendor and product directory names are
kept verbatim to match the existing alsa-ucm-conf tree. The .conf
file follows the alsa-ucm-conf sof/product_configs style with a
biquad summary in comments and the two
Define.PostMixer<Endpoint>Playback{Iir,Fir}Blob keys pointing at the
installed /usr/share/alsa/ucm2/blobs/sof/... paths.

Measurement input is a numeric grid with column 1 = frequency in
Hz and one or more magnitude columns in dB that are averaged.
Plain text and Excel/ODS workbooks are both accepted, dispatched
by file extension. The sof_ucm2_eq_example.{txt,xlsx} files added
in the previous commit let the script be run without external
data:

  sof_ucm2_eq_generate('example', 'example', 'speaker', \
                       'sof_ucm2_eq_example.txt');
  sof_ucm2_eq_generate('example', 'example', 'speaker', \
                       'sof_ucm2_eq_example.xlsx');

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu singalsu force-pushed the add_sof_ucm2_eq_generate branch from 60a9e9a to 8cd5661 Compare July 9, 2026 11:37
@singalsu singalsu requested a review from Copilot July 9, 2026 11:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m
Comment thread src/audio/eq_iir/tune/sof_ucm2_eq_generate.m
@singalsu

singalsu commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Both copilot review comments were false positives, no need to change the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants