hdmi_audio_playback.sh (2403B)
1 #!/bin/bash 2 3 #/* 4 # * Copyright (C) 2013-2016 Intel Corporation 5 # * 6 # * This program is free software; you can redistribute it and/or modify 7 # * it under the terms of the GNU General Public License as published by 8 # * the Free Software Foundation; either version 2 of the License, or 9 # * (at your option) any later version. 10 # * 11 # * This program is distributed in the hope that it will be useful, 12 # * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # * GNU General Public License for more details. 15 # * 16 # */ 17 18 #set test freq table (HZ) 19 freq_table="10 31 73 155 380 977 1932 4119 8197 16197" 20 21 #set test number of channels 22 test_channel=2 23 24 #get device number for HDMI 25 HDMI_device_num=0 26 $ABAT_TEST_PATH/hdmi_audio_subdevice_number.sh 27 HDMI_device_num=$? 28 if [ $HDMI_device_num = 77 ]; then 29 echo "Prompt: Can not get device with HDMI audio or \ 30 show the wrong connection type as DP in ELD info" 31 exit 1 32 fi 33 34 #To get HDMI audio device number 35 HDMI_card_number=$(aplay -l | grep "HDMI 0" | cut -b 6) 36 if [ "$HDMI_card_number" = "" ]; then 37 echo "Error: Can not get Display audio card." 38 exit 1 39 fi 40 41 HDMI_device="hw:$HDMI_card_number,$HDMI_device_num" 42 echo $device 43 sleep 2 44 45 #get Analog audio record card number 46 record_card_number=$(arecord -l | grep "Analog" | cut -b 6) 47 if [ "$record_card_number" = "" ]; then 48 echo "Can not get record card number." 49 exit 1 50 fi 51 52 #get Analog audio record device number 53 record_device_number=$(arecord -l | grep "Analog"| cut -d " " -f 8 |cut -b 1) 54 if [ "$record_device_number" = "" ]; then 55 echo "Can not get record device number" 56 exit 1 57 fi 58 59 #Notice: to loopback the HDMI audio output to the analog audio input 60 record_device="hw:$record_card_number,$record_device_number" 61 test_flag=0 62 63 echo -e "\e[31m Notice: to loopback the HDMI audio output \ 64 to the analog audio input" 65 echo -e "\e[0m" 66 read -p "Press enter to continue" 67 #call alsabat to do the test for each frequency in the freq_table 68 for freq in $freq_table 69 do 70 alsabat -P $HDMI_device -C plug$record_device -c $test_channel -F $freq 71 if [ $? = 0 ]; then 72 echo "Test target frequency:$freq for HDMI audio playback \ 73 -- Passed " >> $ABAT_TEST_LOG_FILE 74 else 75 echo "Test target frequency:$freq for HDMI audio playback \ 76 -- Failed " >> $ABAT_TEST_LOG_FILE 77 test_flag=1 78 fi 79 done 80 81 exit $test_flag