55# # Preconditions:
66# # N/A
77# # Description:
8- # # run arecord on each pepeline
8+ # # run arecord on each pipeline
99# # default duration is 10s
1010# # default loop count is 3
1111# # Case step:
@@ -48,6 +48,12 @@ OPT_HAS_ARG['F']=0 OPT_VAL['F']=0
4848OPT_NAME[' S' ]=' filter_string' OPT_DESC[' S' ]=" run this case on specified pipelines"
4949OPT_HAS_ARG[' S' ]=1 OPT_VAL[' S' ]=" id:any"
5050
51+ OPT_NAME[' R' ]=' samplerate' OPT_DESC[' R' ]=' sample rate'
52+ OPT_HAS_ARG[' R' ]=1 OPT_VAL[' R' ]=48000 # Default sample rate
53+
54+ OPT_NAME[' T' ]=' tplg_filename' OPT_DESC[' T' ]=' new topology filename'
55+ OPT_HAS_ARG[' T' ]=1 OPT_VAL[' T' ]=' ' # Default empty
56+
5157func_opt_parse_option " $@ "
5258
5359tplg=${OPT_VAL['t']}
@@ -56,7 +62,69 @@ duration=${OPT_VAL['d']}
5662loop_cnt=${OPT_VAL['l']}
5763out_dir=${OPT_VAL['o']}
5864file_prefix=${OPT_VAL['f']}
59-
65+ samplerate=${OPT_VAL['R']} # Use the sample rate specified by the -R option
66+ new_tplg_filename=${OPT_VAL['T']} # New topology filename
67+ modprobe_file=" /etc/modprobe.d/tplg_filename.conf"
68+
69+ script_name=$( basename " ${BASH_SOURCE[0]} " )
70+
71+ reboot_file=" /var/tmp/$script_name /rebooted"
72+
73+ if [ -f $reboot_file ]; then
74+ rm " $reboot_file "
75+ sof-kernel-log-check.sh " $KERNEL_CHECKPOINT "
76+ exit $?
77+ fi
78+
79+ # Function to check and update topology filename, reload drivers, and confirm update
80+ update_topology_filename () {
81+ if [[ -f " $modprobe_file " ]]; then
82+ old_topology=$( sudo cat " $modprobe_file " )
83+ echo " Old topology: $old_topology "
84+ fi
85+
86+ # Confirm current topology
87+ tplg_file=$( sudo journalctl -q -k | grep -i ' loading topology' | awk -F: ' { topo=$NF; } END { print topo }' )
88+ echo " Current topology loaded: $tplg_file "
89+
90+ if [[ -n " $new_tplg_filename " ]]; then
91+ echo " options snd-sof-pci tplg_filename=$new_tplg_filename " | sudo tee " $modprobe_file " > /dev/null
92+ echo " Updated topology filename to: $new_tplg_filename "
93+
94+ # Reload drivers
95+ sudo sof-test/tools/kmod/sof_remove.sh
96+ sleep 5
97+ sudo sof-test/tools/kmod/sof_insert.sh
98+ sleep 5
99+
100+ # Confirm updated topology
101+ tplg_file=$( sudo journalctl -q -k | grep -i ' loading topology' | awk -F: ' { topo=$NF; } END { print topo }' )
102+ echo " Updated topology loaded: $tplg_file "
103+ fi
104+ }
105+
106+ # Restore the original topology after the test
107+ restore_topology () {
108+ if [[ -n " $old_topology " ]]; then
109+ # sleep 10
110+ echo " $old_topology " | sudo tee " $modprobe_file " > /dev/null
111+ echo " Restored original topology: $old_topology "
112+ # reboot_wrapper
113+ # Reload drivers to apply the original topology
114+ # sleep 5
115+ # sudo sof-test/tools/kmod/sof_remove.sh
116+ # sleep 5
117+ # sudo sof-test/tools/kmod/sof_insert.sh
118+ # sleep 5
119+
120+ # Confirm restored topology
121+ # tplg_file=$(sudo journalctl -q -k | grep -i 'loading topology' | awk -F: '{ topo=$NF; } END { print topo }')
122+ # echo "Restored topology loaded: $tplg_file"
123+ fi
124+ }
125+
126+ # Update topology filename if -T option is used
127+ update_topology_filename
60128start_test
61129logger_disabled || func_lib_start_log_collect
62130
90158 dlogi " using $file as capture output"
91159 fi
92160
93- if ! arecord_opts -D" $dev " -r " $rate " -c " $channel " -f " $fmt_elem " -d " $duration " " $file " -v -q;
161+ # Ensure the sample rate is set correctly
162+ if ! arecord_opts -D" $dev " -r " $samplerate " -c " $channel " -f " $fmt_elem " -d " $duration " " $file " -v -q;
94163 then
95164 func_lib_lsof_error_dump " $snd "
165+ echo " arecord on PCM $dev failed at $i /$loop_cnt ."
96166 die " arecord on PCM $dev failed at $i /$loop_cnt ."
97167 fi
98168 done
99169 done
100170 done
101171done
102172
103- sof-kernel-log-check.sh " $KERNEL_CHECKPOINT "
104- exit $?
173+ echo " Wait for remove"
174+ # sleep 1000
175+ restore_topology
176+ mkdir -p " /var/tmp/$script_name "
177+ touch " $reboot_file "
0 commit comments