Skip to content

Commit

Permalink
case-lib: is_ipc4: use new debugfs file instead of kernel parameter
Browse files Browse the repository at this point in the history
First step to remove use of kernel parameters

Link: thesofproject/linux#4902
Link: #1166

Signed-off-by: Pierre-Louis Bossart <[email protected]>
  • Loading branch information
plbossart committed Apr 4, 2024
1 parent a2062a3 commit 7e3fc59
Showing 1 changed file with 38 additions and 13 deletions.
51 changes: 38 additions & 13 deletions case-lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -813,22 +813,47 @@ is_firmware_file_zephyr()
is_ipc4()
{
local ipc_type
ipc_file=/sys/module/snd_sof_pci/parameters/ipc_type

# If /sys/module/snd_sof_pci/parameters/ipc_type does not exist
# the DUT is running IPC3 mode
ipc_type=$(cat $ipc_file) || {
return 1
}
if ipc_type=$(cat /sys/kernel/debug/sof/ipc_type); then
# "cat" was successful
case $ipc_type in
0)
return 1
;;
1)
return 0 # in shell, success = error code 0 = "true"
;;
*)
die "invalid ipc_type in /sys/kernel/debug/sof/ipc_type=$ipc_type"
;;
esac
fi

# If /sys/module/snd_sof_pci/parameters/ipc_type exists
# If the value of file ipc_type is:
# -1: DUT runs IPC3 mode, is_ipc4 return 1(false)
# 1: DUT runs IPC4 mode, is_ipc4 return 0(true)
if [ "$ipc_type" -eq 1 ]; then
return 0
# "cat" failed, backwards-compatible fallback with ipc_type kernel parameter
if ipc_type=$(cat /sys/module/snd_sof_pci/parameters/ipc_type); then
# "cat" was successful
case $ipc_type in
-1)
# the parameter is not set, assume IPC3 was used.
return 1
;;
0)
# the parameter is set, IPC3 was used.
return 1
;;
1)
# the parameter is set, IPC4 was used.
return 0 # in shell, success = error code 0 = "true"
;;
*)
die "invalid ipc_type in /sys/module/snd_sof_pci/parameters/ipc_type=$ipc_type"
;;
esac
fi
return 1

# If /sys/module/snd_sof_pci/parameters/ipc_type does not exist
# assume IPC3 was used.
return 1
}

logger_disabled()
Expand Down

0 comments on commit 7e3fc59

Please sign in to comment.