diff --git a/test-case/check-audio-equalizer.sh b/test-case/check-audio-equalizer.sh new file mode 100755 index 00000000..7397d1c6 --- /dev/null +++ b/test-case/check-audio-equalizer.sh @@ -0,0 +1,146 @@ +#!/bin/bash + +## +## Case Name: check-audio-equalizer.sh +## Preconditions: +## SOF Topology should have EQ component(s) in any pipeline +## Description: +## check IIR/FIR config working +## Case step: +## 1. Check if the topology has a EQ component in it +## 2. Test with IIR config list +## 3. Test with FIR config list +## Expect result: +## sof-ctl and aplay should return 0 +## + +# source from the relative path of current folder +source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh + +OPT_OPT_lst['t']='tplg' OPT_DESC_lst['t']='tplg file, default value is env TPLG: $TPLG' +OPT_PARM_lst['t']=1 OPT_VALUE_lst['t']="$TPLG" + +OPT_OPT_lst['d']='duration' OPT_DESC_lst['d']='aplay duration in second' +OPT_PARM_lst['d']=1 OPT_VALUE_lst['d']=5 + +OPT_OPT_lst['l']='loop' OPT_DESC_lst['l']='loop count' +OPT_PARM_lst['l']=1 OPT_VALUE_lst['l']=1 + +OPT_OPT_lst['s']='sof-logger' OPT_DESC_lst['s']="Open sof-logger trace the data will store at $LOG_ROOT" +OPT_PARM_lst['s']=0 OPT_VALUE_lst['s']=1 + +func_opt_parse_option $* +tplg=${OPT_VALUE_lst['t']} +duration=${OPT_VALUE_lst['d']} +loop_cnt=${OPT_VALUE_lst['l']} + +# TODO: direct import only EQ pipeline +func_pipeline_export $tplg "type:playback" +sofcard=${SOFCARD:-0} + +# Test equalizer +func_test_eq() +{ + local id=$1 + local conf=$2 + + [ ! -f $conf ] && dloge "$conf not exist" && exit 1 + + dlogc "sof-ctl -Dhw:$sofcard -n $id -s $conf" + sof-ctl -Dhw:$sofcard -n $id -s $conf + if [ $? -ne 0 ]; then + dloge "Equalizer setting failure with $conf" + return 1 + fi + # test with aplay + dlogc "aplay -D$dev -f $fmt -c $channel -r $rate /dev/zero -d $duration" + aplay -D$dev -f $fmt -c $channel /dev/zero -d $duration + if [ $? -ne 0 ]; then + dloge "Equalizer test failure with $conf" + return 1 + fi + sleep 1 +} + +current_dir=$(dirname ${BASH_SOURCE[0]}) + +# initialized with negative value. If none of test is performed the test result will be failed. +result=1 +failed_cnt=0 + +# TODO: direct import only EQ pipeline and loop for EQ pipeline only +for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1)) +do + dlogi "$idx - total pipeline= $PIPELINE_COUNT" + dev=$(func_pipeline_parse_value $idx dev) + channel=$(func_pipeline_parse_value $idx channel) + rate=$(func_pipeline_parse_value $idx rate) + fmt=$(func_pipeline_parse_value $idx fmt) + eq_support=$(func_pipeline_parse_value $idx eq) + if [ -z "$eq_support" ]; then + dlogi "None of FIR/IIF filter is available in this pipeline, skip" + continue + fi + dlogi "eq_support= $eq_support" + is_iir=$(echo $eq_support | grep -i iir | wc -l) + is_fir=$(echo $eq_support | grep -i fir | wc -l) + if [ $is_iir -ne $is_fir ]; then + dlogi "no FIR or IIF filter is available in this pipeline, skip" + continue + fi + + dlogi "0. Get amixer control id for IIR and FIR" + IIRid=`amixer -D hw:$sofcard controls | grep EQIIR| head -1| sed 's/numid=\([0-9]*\),.*/\1/'` + if [ -z $IIRid ]; then + dloge "can't find IIR filter" + exit 1 + fi + + FIRid=`amixer -D hw:$sofcard controls | grep EQFIR| head -1| sed 's/numid=\([0-9]*\),.*/\1/'` + if [ -z $FIRid ]; then + dloge "can't find FIR filter" + exit 1 + fi + + declare -a IIRList=($(ls -d ${current_dir}/eqctl/eq_iir_*.txt)) + nIIRList=${#IIRList[@]} + dlogi "IIR list $nIIRList ${IIRList[*]}" + declare -a FIRList=($(ls -d ${current_dir}/eqctl/eq_fir_*.txt)) + nFIRList=${#FIRList[@]} + dlogi "FIR list $nFIRList ${FIRList[*]}" + if [ $nIIRList == 0 ] || [ $nFIRList == 0 ]; then + dloge "IIR or FIR flter coeff list error!" + exit 1 + fi + + for i in $(seq 1 $loop_cnt) + do + dlogi "[$i/$loop_cnt] 1. Test IIR config list, IIR amixer control id=$IIRid" + for config in ${IIRList[@]}; do + func_test_eq $IIRid $current_dir/$config + result=$? + if [[ $result -ne 0 ]]; then + dloge "Failed at $config" + let failed_cnt++ + fi + done + + dlogi "[$i/$loop_cnt] 2. Test FIR config list, FIR amixer control id=$FIRid" + for config in ${FIRList[@]}; do + func_test_eq $FIRid $current_dir/$config + result=$? + if [[ $result -ne 0 ]]; then + dloge "Failed at $config" + let failed_cnt++ + fi + done + dlogi "EQ test done: failed_cnt is $failed_cnt" + if [ $failed_cnt -gt 0 ]; then + exit 1 + fi + done + +done + +exit $result + diff --git a/test-case/eqctl/eq_fir_flat.txt b/test-case/eqctl/eq_fir_flat.txt new file mode 100644 index 00000000..4be59009 --- /dev/null +++ b/test-case/eqctl/eq_fir_flat.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..1288bd2f --- /dev/null +++ b/test-case/eqctl/eq_fir_loudness.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..a7536c39 --- /dev/null +++ b/test-case/eqctl/eq_fir_mid.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..5ba02fc7 --- /dev/null +++ b/test-case/eqctl/eq_fir_pass.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..7c6e3f41 --- /dev/null +++ b/test-case/eqctl/eq_iir_bandpass.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..1c874bfe --- /dev/null +++ b/test-case/eqctl/eq_iir_bassboost.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..b62751a8 --- /dev/null +++ b/test-case/eqctl/eq_iir_flat.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..76a52301 --- /dev/null +++ b/test-case/eqctl/eq_iir_loudness.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..e8545206 --- /dev/null +++ b/test-case/eqctl/eq_iir_pass.txt @@ -0,0 +1 @@ +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,