Skip to content

Commit 3f42c3e

Browse files
committed
TinyALSA: Add support for tinymix command
Refactor the volume_basic_test to use lib.sh instead of calling ALSA commands directly, and add support for the tinymix command from TinyALSA. Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
1 parent fdd7ae4 commit 3f42c3e

File tree

2 files changed

+89
-25
lines changed

2 files changed

+89
-25
lines changed

case-lib/lib.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,84 @@ initialize_audio_params()
797797
fi
798798
}
799799

800+
set_sof_volume()
801+
{
802+
local device=$1
803+
local control_name=$2
804+
local value=$3
805+
806+
case "$SOF_ALSA_TOOL" in
807+
'alsa')
808+
dlogc "amixer -c$device' cset 'name=$control_name' '$value'"
809+
amixer -c"$device" cset name="$control_name" "$value" > /dev/null
810+
;;
811+
'tinyalsa')
812+
dlogc "tinymix -D'$device' set '$control_name' '$value'"
813+
tinymix -D"$device" set "$control_name" "$value" > /dev/null
814+
;;
815+
*)
816+
die "Unknown alsa tool $SOF_ALSA_TOOL"
817+
;;
818+
esac
819+
}
820+
821+
get_sof_controls()
822+
{
823+
local sofcard=$1
824+
825+
case "$SOF_ALSA_TOOL" in
826+
'alsa')
827+
amixer -c"$sofcard" controls
828+
;;
829+
'tinyalsa')
830+
tinymix --card "$sofcard" controls
831+
;;
832+
*)
833+
die "Unknown alsa tool $SOF_ALSA_TOOL"
834+
;;
835+
esac
836+
}
837+
838+
kill_play_record()
839+
{
840+
case "$SOF_ALSA_TOOL" in
841+
'alsa')
842+
pkill -9 aplay
843+
;;
844+
'tinyalsa')
845+
pkill -9 tinyplay
846+
;;
847+
*)
848+
die "Unknown alsa tool $SOF_ALSA_TOOL"
849+
;;
850+
esac
851+
}
852+
853+
kill_playrecord_die()
854+
{
855+
kill_play_record
856+
die "$1"
857+
}
858+
859+
check_alsa_tool_process()
860+
{
861+
case "$SOF_ALSA_TOOL" in
862+
"alsa")
863+
# Check if the aplay process is running
864+
pidof -q aplay ||
865+
die "aplay process is terminated too early"
866+
;;
867+
"tinyalsa")
868+
# Check if the tinyplay process is running
869+
pidof -q tinyplay ||
870+
die "tinyplay process is terminated too early"
871+
;;
872+
*)
873+
die "Unknown alsa tool $SOF_ALSA_TOOL"
874+
;;
875+
esac
876+
}
877+
800878
aplay_opts()
801879
{
802880
if [[ "$SOF_ALSA_TOOL" = "tinyalsa" ]]; then

test-case/volume-basic-test.sh

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,41 +39,28 @@ maxloop=${OPT_VAL['l']}
3939

4040
start_test
4141

42-
func_error_exit()
43-
{
44-
dloge "$*"
45-
pkill -9 aplay
46-
exit 1
47-
}
48-
4942
[[ -z $tplg ]] && die "Missing tplg file needed to run"
5043
func_pipeline_export "$tplg" "type:playback"
5144
logger_disabled || func_lib_start_log_collect
5245

5346
[[ $PIPELINE_COUNT -eq 0 ]] && die "Missing playback pipeline for aplay to run"
54-
channel=$(func_pipeline_parse_value 0 channel)
55-
rate=$(func_pipeline_parse_value 0 rate)
56-
fmt=$(func_pipeline_parse_value 0 fmt)
57-
dev=$(func_pipeline_parse_value 0 dev)
58-
59-
dlogc "aplay -D $dev -c $channel -r $rate -f $fmt /dev/zero &"
47+
duration=50 # Duration of playing white noise while testing under tinyalsa
48+
initialize_audio_params "0"
6049
# play into background, this will wake up DSP and IPC. Need to clean after the test
61-
aplay -D "$dev" -c "$channel" -r "$rate" -f "$fmt" /dev/zero &
62-
50+
aplay_opts -D "$dev" -c "$channel" -r "$rate" -f "$fmts" -d "$duration" /dev/zero >/dev/null &
6351
sleep 1
64-
[[ ! $(pidof aplay) ]] && die "aplay process is terminated too early"
65-
52+
check_alsa_tool_process
6653
sofcard=${SOFCARD:-0}
6754

6855
# https://mywiki.wooledge.org/BashFAQ/024 why cant I pipe data to read?
6956
readarray -t pgalist < <("$TOPDIR"/tools/topo_vol_kcontrols.py "$tplg")
7057

7158
# This (1) provides some logging (2) avoids skip_test if amixer fails
72-
amixer -c"$sofcard" controls
59+
get_sof_controls "$sofcard"
7360
dlogi "pgalist number = ${#pgalist[@]}"
7461
[[ ${#pgalist[@]} -ne 0 ]] || skip_test "No PGA control is available"
7562

76-
for i in $(seq 1 $maxloop)
63+
for i in $(seq 1 "$maxloop")
7764
do
7865
setup_kernel_check_point
7966
dlogi "===== Round($i/$maxloop) ====="
@@ -83,21 +70,20 @@ do
8370
dlogi "$volctrl"
8471

8572
for vol in "${volume_array[@]}"; do
86-
dlogc "amixer -c$sofcard cset name='$volctrl' $vol"
87-
amixer -c"$sofcard" cset name="$volctrl" "$vol" > /dev/null ||
88-
func_error_exit "amixer return error, test failed"
73+
set_sof_volume "$sofcard" "$volctrl" "$vol" ||
74+
kill_playrecord_die "mixer return error, test failed"
8975
done
9076
done
9177

9278
sleep 1
9379

9480
dlogi "check dmesg for error"
9581
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT" ||
96-
func_error_exit "dmesg has errors!"
82+
kill_playrecord_die "dmesg has errors!"
9783
done
9884

99-
#clean up background aplay
100-
pkill -9 aplay || true
85+
#clean up background play record
86+
kill_play_record || true
10187

10288
dlogi "Reset all PGA volume to 0dB"
10389
reset_sof_volume || die "Failed to reset some PGA volume to 0dB."

0 commit comments

Comments
 (0)