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#set -x 18 19subdevice_number=0 20get_subdevice=0 21 22#make sure the DP monitor is connected and active 23 24# To get DisplayPort audio device number 25card_number=$(aplay -l | grep "HDMI 1" | cut -b 6) 26echo $card_number 27if [ "$card_number" = "" ]; then 28 echo "Can not get Display audio card." 29 exit 254 30fi 31 32audio_card_dir="/proc/asound/card$card_number/" 33 34cd $audio_card_dir 35 36for file in `ls` 37do 38 #To get the ELD info according to the connented monitor with DisplayPort. 39 if [[ $file == eld* ]]; then 40 let subdevice_number+=1 41 cat $file | grep connection_type | grep DisplayPort > /dev/null 42 if [ $? = 0 ]; then 43 echo "Get the ELD information according to the connented \ 44monitor with DisplayPort." 45 get_subdevice=1 46 break 47 fi 48 fi 49done 50 51#failed to get the subdevice number of DisplayPort audio 52if [ $get_subdevice == 0 ]; then 53 exit 77 54fi 55 56#the subdevice number of DisplayPort audio is 3 57if [ $subdevice_number == 1 ]; then 58 exit 3 59#the subdevice number of DisplayPort audio is 7. 60elif [ $subdevice_number == 2 ]; then 61 exit 7 62#the subdevice number of DisplayPort audio is 8 63elif [ $subdevice_number == 3 ]; then 64 exit 8 65#default: failed to get the subdevice number of DisplayPort audio 66else 67 exit 77 68fi 69