|
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 |
#set -x
|
|
Packit Service |
a9274b |
|
|
Packit Service |
a9274b |
subdevice_number=0
|
|
Packit Service |
a9274b |
get_subdevice=0
|
|
Packit Service |
a9274b |
|
|
Packit Service |
a9274b |
#make sure the DP monitor is connected and active
|
|
Packit Service |
a9274b |
|
|
Packit Service |
a9274b |
# To get DisplayPort audio device number
|
|
Packit Service |
a9274b |
card_number=$(aplay -l | grep "HDMI 1" | cut -b 6)
|
|
Packit Service |
a9274b |
echo $card_number
|
|
Packit Service |
a9274b |
if [ "$card_number" = "" ]; then
|
|
Packit Service |
a9274b |
echo "Can not get Display audio card."
|
|
Packit Service |
a9274b |
exit 254
|
|
Packit Service |
a9274b |
fi
|
|
Packit Service |
a9274b |
|
|
Packit Service |
a9274b |
audio_card_dir="/proc/asound/card$card_number/"
|
|
Packit Service |
a9274b |
|
|
Packit Service |
a9274b |
cd $audio_card_dir
|
|
Packit Service |
a9274b |
|
|
Packit Service |
a9274b |
for file in `ls`
|
|
Packit Service |
a9274b |
do
|
|
Packit Service |
a9274b |
#To get the ELD info according to the connented monitor with DisplayPort.
|
|
Packit Service |
a9274b |
if [[ $file == eld* ]]; then
|
|
Packit Service |
a9274b |
let subdevice_number+=1
|
|
Packit Service |
a9274b |
cat $file | grep connection_type | grep DisplayPort > /dev/null
|
|
Packit Service |
a9274b |
if [ $? = 0 ]; then
|
|
Packit Service |
a9274b |
echo "Get the ELD information according to the connented \
|
|
Packit Service |
a9274b |
monitor with DisplayPort."
|
|
Packit Service |
a9274b |
get_subdevice=1
|
|
Packit Service |
a9274b |
break
|
|
Packit Service |
a9274b |
fi
|
|
Packit Service |
a9274b |
fi
|
|
Packit Service |
a9274b |
done
|
|
Packit Service |
a9274b |
|
|
Packit Service |
a9274b |
#failed to get the subdevice number of DisplayPort audio
|
|
Packit Service |
a9274b |
if [ $get_subdevice == 0 ]; then
|
|
Packit Service |
a9274b |
exit 77
|
|
Packit Service |
a9274b |
fi
|
|
Packit Service |
a9274b |
|
|
Packit Service |
a9274b |
#the subdevice number of DisplayPort audio is 3
|
|
Packit Service |
a9274b |
if [ $subdevice_number == 1 ]; then
|
|
Packit Service |
a9274b |
exit 3
|
|
Packit Service |
a9274b |
#the subdevice number of DisplayPort audio is 7.
|
|
Packit Service |
a9274b |
elif [ $subdevice_number == 2 ]; then
|
|
Packit Service |
a9274b |
exit 7
|
|
Packit Service |
a9274b |
#the subdevice number of DisplayPort audio is 8
|
|
Packit Service |
a9274b |
elif [ $subdevice_number == 3 ]; then
|
|
Packit Service |
a9274b |
exit 8
|
|
Packit Service |
a9274b |
#default: failed to get the subdevice number of DisplayPort audio
|
|
Packit Service |
a9274b |
else
|
|
Packit Service |
a9274b |
exit 77
|
|
Packit Service |
a9274b |
fi
|