Blame bat/tests/hdmi_audio_playback.sh

Packit Service a9274b
#!/bin/bash
Packit Service a9274b
Packit Service a9274b
#/*
Packit Service a9274b
# * Copyright (C) 2013-2016 Intel Corporation
Packit Service a9274b
# *
Packit Service a9274b
# * This program is free software; you can redistribute it and/or modify
Packit Service a9274b
# * it under the terms of the GNU General Public License as published by
Packit Service a9274b
# * the Free Software Foundation; either version 2 of the License, or
Packit Service a9274b
# * (at your option) any later version.
Packit Service a9274b
# *
Packit Service a9274b
# * This program is distributed in the hope that it will be useful,
Packit Service a9274b
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service a9274b
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service a9274b
# * GNU General Public License for more details.
Packit Service a9274b
# *
Packit Service a9274b
# */
Packit Service a9274b
Packit Service a9274b
#set test freq table (HZ)
Packit Service a9274b
freq_table="10 31 73 155 380 977 1932 4119 8197 16197"
Packit Service a9274b
Packit Service a9274b
#set test number of channels
Packit Service a9274b
test_channel=2
Packit Service a9274b
Packit Service a9274b
#get device number for HDMI
Packit Service a9274b
HDMI_device_num=0
Packit Service a9274b
$ABAT_TEST_PATH/hdmi_audio_subdevice_number.sh
Packit Service a9274b
HDMI_device_num=$?
Packit Service a9274b
if [ $HDMI_device_num = 77 ]; then
Packit Service a9274b
	echo "Prompt: Can not get device with HDMI audio or \
Packit Service a9274b
show the wrong connection type as DP in ELD info"
Packit Service a9274b
	exit 1
Packit Service a9274b
fi
Packit Service a9274b
Packit Service a9274b
#To get HDMI audio device number
Packit Service a9274b
HDMI_card_number=$(aplay -l | grep "HDMI 0" | cut -b 6)
Packit Service a9274b
if [ "$HDMI_card_number" = "" ]; then
Packit Service a9274b
        echo "Error: Can not get Display audio card."
Packit Service a9274b
        exit 1
Packit Service a9274b
fi
Packit Service a9274b
Packit Service a9274b
HDMI_device="hw:$HDMI_card_number,$HDMI_device_num"
Packit Service a9274b
echo $device
Packit Service a9274b
sleep 2
Packit Service a9274b
Packit Service a9274b
#get Analog audio record card number
Packit Service a9274b
record_card_number=$(arecord -l | grep "Analog" | cut -b 6)
Packit Service a9274b
if [ "$record_card_number" = "" ]; then
Packit Service a9274b
        echo "Can not get record card number."
Packit Service a9274b
        exit 1
Packit Service a9274b
fi
Packit Service a9274b
Packit Service a9274b
#get Analog audio record device number
Packit Service a9274b
record_device_number=$(arecord -l | grep "Analog"| cut -d " " -f 8 |cut -b 1)
Packit Service a9274b
if [ "$record_device_number" = "" ]; then
Packit Service a9274b
        echo "Can not get record device number"
Packit Service a9274b
        exit 1
Packit Service a9274b
fi
Packit Service a9274b
Packit Service a9274b
#Notice: to loopback the HDMI audio output to the analog audio input
Packit Service a9274b
record_device="hw:$record_card_number,$record_device_number"
Packit Service a9274b
test_flag=0
Packit Service a9274b
Packit Service a9274b
echo -e "\e[31m Notice: to loopback the HDMI audio output \
Packit Service a9274b
to the analog audio input"
Packit Service a9274b
echo -e "\e[0m"
Packit Service a9274b
read -p "Press enter to continue"
Packit Service a9274b
#call alsabat to do the test for each frequency in the freq_table
Packit Service a9274b
for freq in $freq_table
Packit Service a9274b
	do
Packit Service a9274b
		alsabat -P $HDMI_device -C plug$record_device -c $test_channel -F $freq
Packit Service a9274b
		if [ $? = 0 ]; then
Packit Service a9274b
			echo "Test target frequency:$freq for HDMI audio playback \
Packit Service a9274b
-- Passed    " >> $ABAT_TEST_LOG_FILE
Packit Service a9274b
		else
Packit Service a9274b
			echo "Test target frequency:$freq for HDMI audio playback \
Packit Service a9274b
-- Failed    " >> $ABAT_TEST_LOG_FILE
Packit Service a9274b
			test_flag=1
Packit Service a9274b
		fi
Packit Service a9274b
	done
Packit Service a9274b
Packit Service a9274b
exit $test_flag