Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on: [pull_request, workflow_dispatch]
jobs:

shellcheck:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -32,7 +32,7 @@ jobs:
text/x-shellscript shellcheck -x

pylint:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
# :-( https://github.community/t/support-for-yaml-anchors/16128
- uses: actions/checkout@v4
Expand Down
49 changes: 30 additions & 19 deletions test-case/check-audio-equalizer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ set -e

# source from the relative path of current folder
my_dir=$(dirname "${BASH_SOURCE[0]}")
# shellcheck source=case-lib/lib.sh
source "$my_dir"/../case-lib/lib.sh

OPT_NAME['t']='tplg' OPT_DESC['t']="tplg file, default value is env TPLG: $TPLG"
OPT_HAS_ARG['t']=1 OPT_VAL['t']="$TPLG"

OPT_NAME['d']='duration' OPT_DESC['d']='aplay duration in second'
OPT_HAS_ARG['d']=1 OPT_VAL['d']=5
OPT_HAS_ARG['d']=1 OPT_VAL['d']=1

OPT_NAME['l']='loop' OPT_DESC['l']='loop count'
OPT_HAS_ARG['l']=1 OPT_VAL['l']=1
Expand All @@ -48,9 +49,10 @@ func_test_eq()
{
local id=$1
local conf=$2
local double_quoted_id=\""$id"\"

dlogc "sof-ctl -Dhw:$sofcard -n $id -s $conf"
sof-ctl -Dhw:"$sofcard" -n "$id" -s "$conf" || {
dlogc "sof-ctl -Dhw:$sofcard -c name=$double_quoted_id -s $conf"
sof-ctl -Dhw:"$sofcard" -c name="$double_quoted_id" -s "$conf" || {
dloge "Equalizer setting failure with $conf"
return 1
}
Expand All @@ -64,30 +66,41 @@ func_test_eq()
}

# this function performs IIR/FIR filter test
# param1 must be must be iir or fir
# param1 must be must be component name
func_test_filter()
{
local testfilter=$1
dlogi "Get amixer control id for $testfilter"
# TODO: Need to match alsa control id with the filter in the pipeline,
# currently the test discards EQ pipelines except first one.
Filterid=$(amixer -D hw:"$sofcard" controls | sed -n -e "/eq${testfilter}/I "'s/numid=\([0-9]*\),.*/\1/p' | head -1)
Filterid=$("$my_dir"/../tools/topo_effect_kcontrols.py "$tplg" "$testfilter")
if [ -z "$Filterid" ]; then
die "can't find $testfilter"
fi

declare -a FilterList=($(ls -d "${my_dir}"/eqctl/eq_"${testfilter}"_*.txt))
nFilterList=${#FilterList[@]}
dlogi "$testfilter list, num= $nFilterList, coeff files= ${FilterList[*]}"
if is_ipc4; then
ipc_dir="ipc4"
else
ipc_dir="ipc3"
fi

if [[ ${Filterid^^} == *"IIR"* ]]; then
comp_dir="eq_iir"
elif [[ ${Filterid^^} == *"FIR"* ]]; then
comp_dir="eq_fir"
else
die "Not supported control: $Filterid"
fi

nFilterList=$(find "${my_dir}/eqctl/$ipc_dir/$comp_dir/" -name '*.txt' | wc -l)
dlogi "$testfilter list, num= $nFilterList"
if [ "$nFilterList" -eq 0 ]; then
die "$testfilter flter coeff list error!"
fi

for i in $(seq 1 $loop_cnt)
for i in $(seq 1 "$loop_cnt")
do
dlogi "===== [$i/$loop_cnt] Test $testfilter config list, $testfilter amixer control id=$Filterid ====="
for config in "${FilterList[@]}"; do
func_test_eq "$Filterid" "$my_dir/$config" || {
for config in "${my_dir}/eqctl/$ipc_dir/$comp_dir"/*.txt; do
func_test_eq "$Filterid" "$config" || {
dloge "EQ test failed with $config"
: $((failed_cnt++))
}
Expand All @@ -110,7 +123,7 @@ do
rate=$(func_pipeline_parse_value "$idx" rate)
fmt=$(func_pipeline_parse_value "$idx" fmt)
type=$(func_pipeline_parse_value "$idx" type)
eq_support=$(func_pipeline_parse_value "$idx" eq)
IFS=" " read -r -a eq_support <<< "$(func_pipeline_parse_value "$idx" eq)"

case $type in
"playback")
Expand All @@ -123,12 +136,10 @@ do
;;
esac

dlogi "eq_support= $eq_support"
dlogi "eq_support= ${eq_support[*]}"
# if IIR/FIR filter is avilable, test with coef list
for filter_type in iir fir; do
if echo "$eq_support" | grep -q -i $filter_type; then
func_test_filter $filter_type
fi
for comp_id in "${eq_support[@]}"; do
func_test_filter "$comp_id"
done

done
Expand Down
1 change: 0 additions & 1 deletion test-case/eqctl/eq_fir_flat.txt

This file was deleted.

1 change: 0 additions & 1 deletion test-case/eqctl/eq_fir_loudness.txt

This file was deleted.

1 change: 0 additions & 1 deletion test-case/eqctl/eq_fir_mid.txt

This file was deleted.

1 change: 0 additions & 1 deletion test-case/eqctl/eq_fir_pass.txt

This file was deleted.

1 change: 0 additions & 1 deletion test-case/eqctl/eq_iir_bandpass.txt

This file was deleted.

1 change: 0 additions & 1 deletion test-case/eqctl/eq_iir_bassboost.txt

This file was deleted.

1 change: 0 additions & 1 deletion test-case/eqctl/eq_iir_flat.txt

This file was deleted.

1 change: 0 additions & 1 deletion test-case/eqctl/eq_iir_loudness.txt

This file was deleted.

1 change: 0 additions & 1 deletion test-case/eqctl/eq_iir_pass.txt

This file was deleted.

1 change: 1 addition & 0 deletions test-case/eqctl/ipc3/eq_fir/flat.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,88,4607827,0,56,50450433,0,0,0,0,56,65538,0,0,0,0,0,4294901764,0,0,0,0,16384,0
1 change: 1 addition & 0 deletions test-case/eqctl/ipc3/eq_fir/loudness.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,616,4607827,0,584,50450433,0,0,0,0,584,131076,0,0,0,0,65537,65537,4294901764,0,0,0,0,16384,0,252,0,0,0,0,65537,65537,65537,65537,131073,131074,131074,196611,196611,262147,262148,327685,393221,393222,458759,524296,589833,655370,720907,786444,851981,983054,1048591,1179665,1245202,1376276,1507350,1638424,1769498,1966109,2162719,2359330,2621478,2818089,3080237,3407922,3670070,3997755,4325440,4718661,5046347,5505105,5963863,6422622,6815845,7274604,7733362,8192121,8781953,9568396,10420376,11272357,12058802,12976318,14155982,15335649,16056559,16515324,16711960,24117551,70844611,3920495315,3920522431,70845139,24117443,16711983,16515352,16056572,15335663,14156001,12976334,12058814,11272370,10420389,9568408,8781964,8192129,7733369,7274610,6815852,6422629,5963870,5505111,5046353,4718667,4325445,3997760,3670075,3407926,3080242,2818093,2621481,2359334,2162722,1966111,1769501,1638426,1507352,1376278,1245204,1179666,1048593,983055,851982,786445,720908,655371,589834,524297,458760,393223,393222,327685,262149,262148,196611,196611,131075,131074,131074,65537,65537,65537,65537,1,0
1 change: 1 addition & 0 deletions test-case/eqctl/ipc3/eq_fir/pass.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,88,4607827,0,56,50450433,0,0,0,0,56,65538,0,0,0,0,4294967295,4294901764,0,0,0,0,16384,0
1 change: 1 addition & 0 deletions test-case/eqctl/ipc3/eq_iir/bassboost.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,148,4607827,0,116,50450433,0,0,0,0,116,2,1,0,0,0,0,0,0,2,2,0,0,0,0,3227172081,2141520527,536653443,3221660410,536653443,0,16384,3260252783,2107733822,161646111,3961037800,172645501,4294967294,27910
1 change: 1 addition & 0 deletions test-case/eqctl/ipc3/eq_iir/flat.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,120,4607827,0,88,50450433,0,0,0,0,88,2,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,538145694,0,32690
1 change: 1 addition & 0 deletions test-case/eqctl/ipc3/eq_iir/highpass_100hz_0db_48khz.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,120,4607827,0,88,50450433,0,0,0,0,88,2,1,0,0,0,0,0,0,1,1,0,0,0,0,3240919741,2127607086,533187596,3228592105,533187596,0,32692
1 change: 1 addition & 0 deletions test-case/eqctl/ipc3/eq_iir/loudness.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,236,4607827,0,204,50450433,0,0,0,0,204,4,2,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,538145694,0,32690,3,3,0,0,0,0,3237960220,2130690484,297056159,3694463533,303476880,0,16384,3302357025,2064935920,245217319,3776455865,274003881,0,16384,4106268671,4130185751,69182517,4179658584,365641401,4294967292,25468
1 change: 1 addition & 0 deletions test-case/eqctl/ipc3/eq_iir/pass.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,120,4607827,0,88,50450433,0,0,0,0,88,2,1,0,0,0,0,4294967295,4294967295,1,1,0,0,0,0,0,0,0,0,538145694,0,32690
1 change: 1 addition & 0 deletions test-case/eqctl/ipc4/eq_fir/flat.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,88,877023059,0,56,50450433,0,0,0,0,56,65538,0,0,0,0,0,4294901764,0,0,0,0,16384,0
1 change: 1 addition & 0 deletions test-case/eqctl/ipc4/eq_fir/loudness.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,616,877023059,0,584,50450433,0,0,0,0,584,131076,0,0,0,0,65537,65537,4294901764,0,0,0,0,16384,0,252,0,0,0,0,65537,65537,65537,65537,131073,131074,131074,196611,196611,262147,262148,327685,393221,393222,458759,524296,589833,655370,720907,786444,851981,983054,1048591,1179665,1245202,1376276,1507350,1638424,1769498,1966109,2162719,2359330,2621478,2818089,3080237,3407922,3670070,3997755,4325440,4718661,5046347,5505105,5963863,6422622,6815845,7274604,7733362,8192121,8781953,9568396,10420376,11272357,12058802,12976318,14155982,15335649,16056559,16515324,16711960,24117551,70844611,3920495315,3920522431,70845139,24117443,16711983,16515352,16056572,15335663,14156001,12976334,12058814,11272370,10420389,9568408,8781964,8192129,7733369,7274610,6815852,6422629,5963870,5505111,5046353,4718667,4325445,3997760,3670075,3407926,3080242,2818093,2621481,2359334,2162722,1966111,1769501,1638426,1507352,1376278,1245204,1179666,1048593,983055,851982,786445,720908,655371,589834,524297,458760,393223,393222,327685,262149,262148,196611,196611,131075,131074,131074,65537,65537,65537,65537,1,0
1 change: 1 addition & 0 deletions test-case/eqctl/ipc4/eq_fir/pass.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,88,877023059,0,56,50450433,0,0,0,0,56,65538,0,0,0,0,4294967295,4294901764,0,0,0,0,16384,0
1 change: 1 addition & 0 deletions test-case/eqctl/ipc4/eq_iir/bassboost.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,148,877023059,0,116,50450433,0,0,0,0,116,2,1,0,0,0,0,0,0,2,2,0,0,0,0,3227172081,2141520527,536653443,3221660410,536653443,0,16384,3260252783,2107733822,161646111,3961037800,172645501,4294967294,27910
1 change: 1 addition & 0 deletions test-case/eqctl/ipc4/eq_iir/flat.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,120,877023059,0,88,50450433,0,0,0,0,88,2,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,538145694,0,32690
1 change: 1 addition & 0 deletions test-case/eqctl/ipc4/eq_iir/highpass_100hz_0db_48khz.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,120,877023059,0,88,50450433,0,0,0,0,88,2,1,0,0,0,0,0,0,1,1,0,0,0,0,3240919741,2127607086,533187596,3228592105,533187596,0,32692
1 change: 1 addition & 0 deletions test-case/eqctl/ipc4/eq_iir/loudness.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,236,877023059,0,204,50450433,0,0,0,0,204,4,2,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,538145694,0,32690,3,3,0,0,0,0,3237960220,2130690484,297056159,3694463533,303476880,0,16384,3302357025,2064935920,245217319,3776455865,274003881,0,16384,4106268671,4130185751,69182517,4179658584,365641401,4294967292,25468
1 change: 1 addition & 0 deletions test-case/eqctl/ipc4/eq_iir/pass.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3,120,877023059,0,88,50450433,0,0,0,0,88,2,1,0,0,0,0,4294967295,4294967295,1,1,0,0,0,0,0,0,0,0,538145694,0,32690
53 changes: 53 additions & 0 deletions tools/topo_effect_kcontrols.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3

"""Parses the .tplg file argument and returns a list of effect
kcontrols of BYTES type, one per line.

Pro tip: try using these commands _interactively_ with ipython3
"""

# Keep this script short and simple. If you want to get something else
# from .tplg files, create another script.

import sys
from tplgtool2 import TplgBinaryFormat, TplgType, DapmType, has_wname_prefix

TPLG_FORMAT = TplgBinaryFormat()

def main():
"Main"

parsed_tplg = TPLG_FORMAT.parse_file(sys.argv[1])
component = sys.argv[2]

# pylint: disable=invalid-name
DAPMs = [
item for item in parsed_tplg if item.header.type == TplgType.DAPM_WIDGET.name
]

for dapm in DAPMs:
effect_blocks = [b for b in dapm.blocks if b.widget.id == DapmType.EFFECT.name]

for gb in effect_blocks:
if gb.widget.name == component:
print_bytes_kcontrols(gb)


def print_bytes_kcontrols(effect_block):
"Print bytes kcontrols"

bytes_kcontrols = [
kc
for kc in effect_block.kcontrols
if kc.hdr.type == 'BYTES'
]

wname_prefix = (
f"{effect_block.widget.name} " if has_wname_prefix(effect_block.widget) else ""
)

for vkc in bytes_kcontrols:
print(wname_prefix + vkc.hdr.name)

if __name__ == "__main__":
main()
28 changes: 1 addition & 27 deletions tools/topo_vol_kcontrols.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# from .tplg files, create another script.

import sys
from tplgtool2 import TplgBinaryFormat, TplgType, DapmType, SofVendorToken
from tplgtool2 import TplgBinaryFormat, TplgType, DapmType, SofVendorToken, has_wname_prefix

TPLG_FORMAT = TplgBinaryFormat()

Expand Down Expand Up @@ -58,31 +58,5 @@ def print_volume_kcontrols(gain_block):
print(wname_prefix + vkc.hdr.name)


# This could probably be moved to tplgtool2.py?
def has_wname_prefix(widget):
"""Is the kcontrol name prefixed with the widget name? ("PGAxx" or "Dmicxx")
Check SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME"""

wname_elems = [
prv.elems
for prv in widget.priv
if prv.elems[0].token
== SofVendorToken.SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME.name
]

if len(wname_elems) == 0: # typically: topo v1
no_wname_prefix = 0
elif len(wname_elems) == 1: # typically: topo v2
assert len(wname_elems[0]) == 1
no_wname_prefix = wname_elems[0][0].value
else:
assert False, f"Unexpected len of wname_elems={wname_elems}"

assert no_wname_prefix in (0, 1)

# Double-negation: "no_wname false" => prefix
return not no_wname_prefix


if __name__ == "__main__":
main()
25 changes: 25 additions & 0 deletions tools/tplgtool2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,31 @@ def find_interweaved_pipelines(self) -> "list[tuple[Container, list[Container]]]
pipelines.append((comps[0], [self._nodes_dict[name] for name in endpoints if name.startswith('PCM')]))
return pipelines

def has_wname_prefix(widget):
"""Is the kcontrol name prefixed with the widget name? ("PGAxx" or "Dmicxx")
Check SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME"""

wname_elems = [
prv.elems
for prv in widget.priv
if prv.elems[0].token
== SofVendorToken.SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME.name
]

if len(wname_elems) == 0: # typically: topo v1
no_wname_prefix = 0
elif len(wname_elems) == 1: # typically: topo v2
assert len(wname_elems[0]) == 1
no_wname_prefix = wname_elems[0][0].value
else:
assert False, f"Unexpected len of wname_elems={wname_elems}"

assert no_wname_prefix in (0, 1)

# Double-negation: "no_wname false" => prefix
return not no_wname_prefix


if __name__ == "__main__":
from pathlib import Path

Expand Down
Loading