firmware-open/scripts/realtek-coeffs.sh

38 lines
897 B
Bash
Raw Permalink Normal View History

2021-07-20 09:31:25 -06:00
#!/usr/bin/env bash
if [ "${EUID}" != "0" ]
then
exec sudo "$0" "$@"
fi
set -e
for codec in /dev/snd/hw*
do
codec_id="$(basename "${codec}")"
codec_sys="/sys/class/sound/${codec_id}"
vendor="$(cat "${codec_sys}/vendor_name")"
chip="$(cat "${codec_sys}/chip_name")"
if [ "${vendor}" = "Realtek" ]
2021-07-20 09:31:25 -06:00
then
echo "# ${codec_id}: ${vendor} ${chip}"
# Realtek vendor node
nid=0x20
# Get processing capabilities
proc_cap="$(hda-verb "${codec}" "${nid}" PARAMETERS PROC_CAP 2>/dev/null | cut -d " " -f 3)"
seq "$(("${proc_cap}" >> 8))" | while read index
do
# Set coefficient index
index_hex="$(printf "0x%02x\n" "${index}")"
hda-verb "${codec}" "${nid}" SET_COEF_INDEX "${index_hex}" >/dev/null 2>&1
2021-07-20 09:31:25 -06:00
# Get processing coefficient
value="$(hda-verb "${codec}" "${nid}" GET_PROC_COEF 0 2>/dev/null | cut -d " " -f 3)"
echo "${index_hex}: ${value}"
done
fi
done