@@ -1425,3 +1425,55 @@ reboot_wrapper()
14251425 echo " Reboot command" && sleep 5
14261426 sudo reboot now
14271427}
1428+
1429+ check_topology () {
1430+ # Confirm topology on the dut
1431+ tplg_file=$( sudo journalctl -q -k | grep -i ' loading topology' | awk -F: ' { topo=$NF; } END { print topo }' )
1432+ echo " Updated topology loaded: $tplg_file "
1433+ }
1434+
1435+ # Function to check and update topology filename, reload drivers, and confirm update
1436+ update_topology_filename () {
1437+ firmware_dir=" /lib/firmware/intel/"
1438+ modprobe_file=" /etc/modprobe.d/tplg_filename.conf"
1439+ remove_script=" $SCRIPT_HOME /tools/kmod/sof_remove.sh"
1440+ insert_script=" $SCRIPT_HOME /sof-test/tools/kmod/sof_insert.sh"
1441+ if ! find " $firmware_dir " -type f -name " $new_tplg_filename " -print -quit | grep -q . ; then
1442+ echo " File $new_tplg_filename does not exist in $firmware_dir or its subdirectories, exiting."
1443+ exit 1
1444+ fi
1445+ if [[ -f " $modprobe_file " ]]; then
1446+ old_topology=$( sudo cat " $modprobe_file " )
1447+ echo " Old topology: $old_topology "
1448+ fi
1449+ # Check if the remove and insert scripts exist
1450+ if [[ ! -f " $remove_script " ]]; then
1451+ echo " Error: File $remove_script does not exist. Exiting."
1452+ exit 1
1453+ fi
1454+
1455+ if [[ ! -f " $insert_script " ]]; then
1456+ echo " Error: File $insert_script does not exist. Exiting."
1457+ exit 1
1458+ fi
1459+
1460+ if [[ -n " $new_tplg_filename " ]]; then
1461+ echo " options snd-sof-pci tplg_filename=$new_tplg_filename " | sudo tee " $modprobe_file " > /dev/null
1462+ echo " Updated topology filename to: $new_tplg_filename "
1463+
1464+ # Reload drivers
1465+ echo " Reloading drivers"
1466+ sudo " $remove_script "
1467+ sudo " $insert_script "
1468+ check_topology
1469+ fi
1470+ }
1471+
1472+ # Restore the original topology after the test
1473+ restore_topology () {
1474+ echo " $old_topology " | sudo tee " $modprobe_file " > /dev/null
1475+ echo " Restored original topology: $old_topology "
1476+ sudo " $remove_script "
1477+ sudo " $insert_script "
1478+ check_topology
1479+ }
0 commit comments