diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1cc5671c..3fd65bc7 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -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: @@ -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 diff --git a/test-case/check-audio-equalizer.sh b/test-case/check-audio-equalizer.sh index 7cc51890..6537ca64 100755 --- a/test-case/check-audio-equalizer.sh +++ b/test-case/check-audio-equalizer.sh @@ -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 @@ -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 } @@ -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++)) } @@ -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") @@ -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 diff --git a/test-case/eqctl/eq_fir_flat.txt b/test-case/eqctl/eq_fir_flat.txt deleted file mode 100644 index 4be59009..00000000 --- a/test-case/eqctl/eq_fir_flat.txt +++ /dev/null @@ -1 +0,0 @@ -4607827,0,56,50331648,0,0,0,0,56,65538,0,0,0,0,0,4294901764,0,0,0,0,16384,0, diff --git a/test-case/eqctl/eq_fir_loudness.txt b/test-case/eqctl/eq_fir_loudness.txt deleted file mode 100644 index 1288bd2f..00000000 --- a/test-case/eqctl/eq_fir_loudness.txt +++ /dev/null @@ -1 +0,0 @@ -4607827,0,256,50331648,0,0,0,0,256,131076,0,0,0,0,65537,65537,4294901764,0,0,0,0,16384,0,88,0,0,0,0,3535366939,119016436,49938453,30147089,30343698,30409180,29426121,27328945,25428369,23921015,22479202,20906315,19267889,17826074,16646407,15663350,14745832,13762777,12845259,11862204,10879149,10027167,9175186,8388742,7602298,6946927,6291557,5636187,5046354,4522057,3997761,3539002,3145779,2752557,2424872,2162723,1900575,1638427,1441815,1245204,1048593,917519,720909,7, diff --git a/test-case/eqctl/eq_fir_mid.txt b/test-case/eqctl/eq_fir_mid.txt deleted file mode 100644 index a7536c39..00000000 --- a/test-case/eqctl/eq_fir_mid.txt +++ /dev/null @@ -1 +0,0 @@ -4607827,0,216,50331648,0,0,0,0,216,65538,0,0,0,0,0,65620,0,0,0,0,1216113787,4258079667,3890735935,4020759377,4107596501,4148819496,4185192544,4218550909,4245879886,4266982846,4282777302,4294049699,6488112,11010187,13303997,13893842,13435090,12189892,10617006,8847509,7143546,5570657,4194378,3014711,2097190,1310746,786448,393224,65539,4294901760,4294836222,4294836221,4294770684,4294836221,4294836221,4294901757,4294901758,4294901758,4294967295,4294967295,4294967295,0, diff --git a/test-case/eqctl/eq_fir_pass.txt b/test-case/eqctl/eq_fir_pass.txt deleted file mode 100644 index 5ba02fc7..00000000 --- a/test-case/eqctl/eq_fir_pass.txt +++ /dev/null @@ -1 +0,0 @@ -4607827,0,56,50331648,0,0,0,0,56,65538,0,0,0,0,4294967295,4294901764,0,0,0,0,16384,0, diff --git a/test-case/eqctl/eq_iir_bandpass.txt b/test-case/eqctl/eq_iir_bandpass.txt deleted file mode 100644 index 7c6e3f41..00000000 --- a/test-case/eqctl/eq_iir_bandpass.txt +++ /dev/null @@ -1 +0,0 @@ -4607827,0,116,50331648,0,0,0,0,116,2,1,0,0,0,0,0,0,2,2,0,0,0,0,3316150158,2048164275,513807534,3267352229,513807534,0,16384,3867454526,1191025347,38870735,77741469,38870735,4294967292,24197, diff --git a/test-case/eqctl/eq_iir_bassboost.txt b/test-case/eqctl/eq_iir_bassboost.txt deleted file mode 100644 index 1c874bfe..00000000 --- a/test-case/eqctl/eq_iir_bassboost.txt +++ /dev/null @@ -1 +0,0 @@ -4607827,0,116,50331648,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, diff --git a/test-case/eqctl/eq_iir_flat.txt b/test-case/eqctl/eq_iir_flat.txt deleted file mode 100644 index b62751a8..00000000 --- a/test-case/eqctl/eq_iir_flat.txt +++ /dev/null @@ -1 +0,0 @@ -4607827,0,88,50331648,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, diff --git a/test-case/eqctl/eq_iir_loudness.txt b/test-case/eqctl/eq_iir_loudness.txt deleted file mode 100644 index 76a52301..00000000 --- a/test-case/eqctl/eq_iir_loudness.txt +++ /dev/null @@ -1 +0,0 @@ -4607827,0,204,50331648,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, diff --git a/test-case/eqctl/eq_iir_pass.txt b/test-case/eqctl/eq_iir_pass.txt deleted file mode 100644 index e8545206..00000000 --- a/test-case/eqctl/eq_iir_pass.txt +++ /dev/null @@ -1 +0,0 @@ -4607827,0,88,50331648,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, diff --git a/test-case/eqctl/ipc3/eq_fir/flat.txt b/test-case/eqctl/ipc3/eq_fir/flat.txt new file mode 100644 index 00000000..ed8f327e --- /dev/null +++ b/test-case/eqctl/ipc3/eq_fir/flat.txt @@ -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 diff --git a/test-case/eqctl/ipc3/eq_fir/loudness.txt b/test-case/eqctl/ipc3/eq_fir/loudness.txt new file mode 100644 index 00000000..40cc0f19 --- /dev/null +++ b/test-case/eqctl/ipc3/eq_fir/loudness.txt @@ -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 diff --git a/test-case/eqctl/ipc3/eq_fir/pass.txt b/test-case/eqctl/ipc3/eq_fir/pass.txt new file mode 100644 index 00000000..501ef282 --- /dev/null +++ b/test-case/eqctl/ipc3/eq_fir/pass.txt @@ -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 diff --git a/test-case/eqctl/ipc3/eq_iir/bassboost.txt b/test-case/eqctl/ipc3/eq_iir/bassboost.txt new file mode 100644 index 00000000..82e849f5 --- /dev/null +++ b/test-case/eqctl/ipc3/eq_iir/bassboost.txt @@ -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 diff --git a/test-case/eqctl/ipc3/eq_iir/flat.txt b/test-case/eqctl/ipc3/eq_iir/flat.txt new file mode 100644 index 00000000..25fc6796 --- /dev/null +++ b/test-case/eqctl/ipc3/eq_iir/flat.txt @@ -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 diff --git a/test-case/eqctl/ipc3/eq_iir/highpass_100hz_0db_48khz.txt b/test-case/eqctl/ipc3/eq_iir/highpass_100hz_0db_48khz.txt new file mode 100644 index 00000000..77cb790f --- /dev/null +++ b/test-case/eqctl/ipc3/eq_iir/highpass_100hz_0db_48khz.txt @@ -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 diff --git a/test-case/eqctl/ipc3/eq_iir/loudness.txt b/test-case/eqctl/ipc3/eq_iir/loudness.txt new file mode 100644 index 00000000..1cf6a66f --- /dev/null +++ b/test-case/eqctl/ipc3/eq_iir/loudness.txt @@ -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 diff --git a/test-case/eqctl/ipc3/eq_iir/pass.txt b/test-case/eqctl/ipc3/eq_iir/pass.txt new file mode 100644 index 00000000..ce79acad --- /dev/null +++ b/test-case/eqctl/ipc3/eq_iir/pass.txt @@ -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 diff --git a/test-case/eqctl/ipc4/eq_fir/flat.txt b/test-case/eqctl/ipc4/eq_fir/flat.txt new file mode 100644 index 00000000..5fd026ca --- /dev/null +++ b/test-case/eqctl/ipc4/eq_fir/flat.txt @@ -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 diff --git a/test-case/eqctl/ipc4/eq_fir/loudness.txt b/test-case/eqctl/ipc4/eq_fir/loudness.txt new file mode 100644 index 00000000..e5093f01 --- /dev/null +++ b/test-case/eqctl/ipc4/eq_fir/loudness.txt @@ -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 diff --git a/test-case/eqctl/ipc4/eq_fir/pass.txt b/test-case/eqctl/ipc4/eq_fir/pass.txt new file mode 100644 index 00000000..5decf09a --- /dev/null +++ b/test-case/eqctl/ipc4/eq_fir/pass.txt @@ -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 diff --git a/test-case/eqctl/ipc4/eq_iir/bassboost.txt b/test-case/eqctl/ipc4/eq_iir/bassboost.txt new file mode 100644 index 00000000..8d96a8c7 --- /dev/null +++ b/test-case/eqctl/ipc4/eq_iir/bassboost.txt @@ -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 diff --git a/test-case/eqctl/ipc4/eq_iir/flat.txt b/test-case/eqctl/ipc4/eq_iir/flat.txt new file mode 100644 index 00000000..cb78a292 --- /dev/null +++ b/test-case/eqctl/ipc4/eq_iir/flat.txt @@ -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 diff --git a/test-case/eqctl/ipc4/eq_iir/highpass_100hz_0db_48khz.txt b/test-case/eqctl/ipc4/eq_iir/highpass_100hz_0db_48khz.txt new file mode 100644 index 00000000..144df136 --- /dev/null +++ b/test-case/eqctl/ipc4/eq_iir/highpass_100hz_0db_48khz.txt @@ -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 diff --git a/test-case/eqctl/ipc4/eq_iir/loudness.txt b/test-case/eqctl/ipc4/eq_iir/loudness.txt new file mode 100644 index 00000000..fed1b4f2 --- /dev/null +++ b/test-case/eqctl/ipc4/eq_iir/loudness.txt @@ -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 diff --git a/test-case/eqctl/ipc4/eq_iir/pass.txt b/test-case/eqctl/ipc4/eq_iir/pass.txt new file mode 100644 index 00000000..ee0d545e --- /dev/null +++ b/test-case/eqctl/ipc4/eq_iir/pass.txt @@ -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 diff --git a/tools/topo_effect_kcontrols.py b/tools/topo_effect_kcontrols.py new file mode 100755 index 00000000..cc973771 --- /dev/null +++ b/tools/topo_effect_kcontrols.py @@ -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() diff --git a/tools/topo_vol_kcontrols.py b/tools/topo_vol_kcontrols.py index 1f1c5cc5..a08f5845 100755 --- a/tools/topo_vol_kcontrols.py +++ b/tools/topo_vol_kcontrols.py @@ -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() @@ -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() diff --git a/tools/tplgtool2.py b/tools/tplgtool2.py index 5d8613ed..0adfb998 100755 --- a/tools/tplgtool2.py +++ b/tools/tplgtool2.py @@ -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