@@ -47,25 +47,35 @@ source "${TESTLIB}/lib.sh"
4747source " ${TESTLIB} /relay.sh"
4848
4949# shellcheck disable=SC2153
50- OPT_NAME[' t' ]=' tplg' OPT_DESC[' t' ]=" tplg file, default value is env TPLG: $TPLG "
51- OPT_HAS_ARG[' t' ]=1 OPT_VAL[' t' ]=" $TPLG "
50+ OPT_NAME[' t' ]=' tplg' OPT_DESC[' t' ]=" tplg file, default value is env TPLG: $TPLG "
51+ OPT_HAS_ARG[' t' ]=1 OPT_VAL[' t' ]=" $TPLG "
5252
53- OPT_NAME[' l' ]=' loop' OPT_DESC[' l' ]=' loop count'
54- OPT_HAS_ARG[' l' ]=1 OPT_VAL[' l' ]=1
53+ OPT_NAME[' l' ]=' loop' OPT_DESC[' l' ]=' loop count'
54+ OPT_HAS_ARG[' l' ]=1 OPT_VAL[' l' ]=1
5555
56- OPT_NAME[' s' ]=' sof-logger' OPT_DESC[' s' ]=" Open sof-logger trace the data will store at $LOG_ROOT "
57- OPT_HAS_ARG[' s' ]=0 OPT_VAL[' s' ]=1
56+ OPT_NAME[' s' ]=' sof-logger' OPT_DESC[' s' ]=" Open sof-logger trace the data will store at $LOG_ROOT "
57+ OPT_HAS_ARG[' s' ]=0 OPT_VAL[' s' ]=1
5858
59- OPT_NAME[' u' ]=' relay' OPT_DESC[' u' ]=' name of usbrelay switch, default value is HURTM_2'
60- OPT_HAS_ARG[' u' ]=1 OPT_VAL[' u' ]=" HURTM_2"
59+ OPT_NAME[' d' ]=' dsp-settle-sleep' OPT_DESC[' d' ]=" Waitng time to change control state"
60+ OPT_HAS_ARG[' d' ]=1 OPT_VAL[' d' ]=3
61+
62+ OPT_NAME[' u' ]=' relay' OPT_DESC[' u' ]=' name of usbrelay switch, default value is HURTM_2'
63+ OPT_HAS_ARG[' u' ]=1 OPT_VAL[' u' ]=" HURTM_2"
64+
65+ OPT_NAME[' H' ]=' headphone' OPT_DESC[' H' ]=' name of pcm control for headphone jack'
66+ OPT_HAS_ARG[' H' ]=1 OPT_VAL[' H' ]=" headphone jack"
67+
68+ OPT_NAME[' M' ]=' headset' OPT_DESC[' M' ]=' name of pcm control for headset mic jack'
69+ OPT_HAS_ARG[' M' ]=1 OPT_VAL[' M' ]=" headset [a-z ]*jack"
6170
6271func_opt_parse_option " $@ "
6372
6473tplg=${OPT_VAL['t']}
6574relay=${OPT_VAL['u']}
6675loop_cnt=${OPT_VAL['l']}
67-
68- DSP_SETTLE_TIME=2
76+ dsp_settle_time=${OPT_VAL['d']}
77+ headphone_jack_name=${OPT_VAL['H']}
78+ headset_mic_jack_name=${OPT_VAL['M']}
6979
7080check_control_switch_state ()
7181{
@@ -77,16 +87,8 @@ check_control_switch_state()
7787 local expected_control_state=" $2 "
7888 local control_state
7989
80- control_state=$( amixer -c " $SOFCARD " contents | awk -v name=" $control_name " '
81- BEGIN {
82- RS = "";
83- IGNORECASE = 1;
84- split(name, parts, " ");
85- };
86- $0 ~ parts[1] && $0 ~ parts[2] {
87- if (match($0, /values=(on|off)/, m)) print m[1];
88- }
89- ' )
90+ control_state=$( amixer -c " $SOFCARD " contents | \
91+ gawk -v name=" $control_name " -f " ${TESTLIB} /control_state.awk" )
9092 dlogi " $control_name switch is: $control_state "
9193
9294 if [[ " $expected_control_state " == " $control_state " ]]; then
@@ -116,40 +118,40 @@ testing_one_pcm()
116118 usbrelay_switch " $relay " 1
117119
118120 # Wait for a short period to allow the system to detect the unplug event
119- sleep $DSP_SETTLE_TIME
121+ sleep " $dsp_settle_time "
120122
121123 # check if the aplay process is still running after unplugging the jack
122124 ps -p " $pid_playback " > /dev/null || {
123125 func_lib_lsof_error_dump " $snd "
124126 die " Playback process terminated unexpectedly after unplugging the jack."
125127 }
126128
127- check_control_switch_state " headset " " off" || {
128- die " unplug headset jack failed."
129+ check_control_switch_state " $headset_mic_jack_name " " off" || {
130+ die " unplug $headset_mic_jack_name jack failed."
129131 }
130132
131- check_control_switch_state " headphone " ' off' || {
132- die " unplug headphone jack failed."
133+ check_control_switch_state " $headphone_jack_name " " off" || {
134+ die " unplug $headphone_jack_name jack failed."
133135 }
134136
135137 dlogi " Plug jack audio."
136138 usbrelay_switch " $relay " 0
137139
138140 # Wait for a short period to allow the system to detect the plug event
139- sleep $DSP_SETTLE_TIME
141+ sleep " $dsp_settle_time "
140142
141143 # check if the aplay process is still running after unplugging the jack
142144 ps -p " $pid_playback " > /dev/null || {
143145 func_lib_lsof_error_dump " $snd "
144146 die " Playback process terminated unexpectedly after plugging the jack."
145147 }
146148
147- check_control_switch_state " headset " " on" || {
148- die " Plug headset jack failed."
149+ check_control_switch_state " $headset_mic_jack_name " " on" || {
150+ die " Plug $headset_mic_jack_name failed."
149151 }
150152
151- check_control_switch_state " headphone " " on" || {
152- die " Plug headphone jack failed."
153+ check_control_switch_state " $headphone_jack_name " " on" || {
154+ die " Plug $headphone_jack_name jack failed."
153155 }
154156
155157 kill -9 $pid_playback > /dev/null 2>&1
@@ -185,6 +187,9 @@ main()
185187 dlogi " Reset - plug jack audio"
186188 usbrelay_switch " $relay " 0
187189
190+ dlogi " Headphone patten: $headphone_jack_name "
191+ dlogi " Headset mic pattern: $headset_mic_jack_name "
192+
188193 for idx in $( seq 0 $(( PIPELINE_COUNT - 1 )) )
189194 do
190195 initialize_audio_params " $idx "
0 commit comments